Elasticsearch滚动API错误:RequestError(400,'ElasticsearchIllegalArgumentException[未能解码滚动ID])

2024-09-30 18:28:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在使用Elasticsearch 1.3.4

通过Python ES客户端使用scroll API时(摘自this示例:

page = es.search(
    index = INDEX_NAME,
    scroll = '1m',
    size = 1000,
    body={"query": {"match_all": {}}})
    sid = page['_scroll_id']
    scroll_size = page['hits']['total']

    # Start scrolling

    print( "Scrolling...")
    while (scroll_size > 0):


        print("Page: ",count)
        page = es.scroll(scroll_id = sid, scroll = '10m')
        # Update the scroll ID
        sid = page['_scroll_id']

        for hit in page['hits']['hits']:
            #some code processing here

我得到了以下错误:

elasticsearch.exceptions.RequestError: RequestError(400, 'ElasticsearchIllegalArgumentException[Failed to decode scrollId]; nested: IOException[Bad Base64 input character decimal 123 in array position 0]; ', 'ElasticsearchIllegalArgumentException[Failed to decode scrollId]; nested: IOException[Bad Base64 input character decimal 123 in array position 0]; ')

当在另一个elasticsearch(5.5.2)中使用相同的代码时,效果非常好

谷歌搜索让我找到了这个page,这表明ES版本<;=1.5中存在这个问题

我想知道是否有办法在不更新ES的情况下解决这个问题,或者我必须更新ES或者根本不使用Scroll

提前谢谢你


Tags: toinidsizeespageelasticsearchprint