gpt4 book ai didi

python - helpers.scan() 不滚动 - ElasticSearch

转载 作者:太空宇宙 更新时间:2023-11-03 14:15:22 25 4
gpt4 key购买 nike

我无法扫描整个 ElasticSearch 索引。

ElasticSearch版本:1.7.5

我正在尝试扫描索引,但在获取 1000 个文档后它总是失败。

res = helpers.scan(es, index="twitter", query={"query": {"match_all": {}}},
request_timeout=60)

for hit in res:
do_some_stuff()

回溯:

WARNING:elasticsearch:GET http://example.com:9200/_search/scroll?scroll=5m [status:400 request:0.002s]
WARNING:elasticsearch:DELETE http://example.com:9200/_search/scroll [status:400 request:0.001s]
Traceback (most recent call last):
File "/project/.env/lib/python3.5/site-packages/elasticsearch/helpers/__init__.py", line 301, in scan
resp = client.scroll(scroll_id, scroll=scroll, request_timeout=request_timeout)
File "/project/.env/lib/python3.5/site-packages/elasticsearch/client/utils.py", line 73, in _wrapped
return func(*args, params=params, **kwargs)
File "/project/.env/lib/python3.5/site-packages/elasticsearch/client/__init__.py", line 1024, in scroll
params=params, body=body)
File "/project/.env/lib/python3.5/site-packages/elasticsearch/transport.py", line 312, in perform_request
status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
File "/project/.env/lib/python3.5/site-packages/elasticsearch/connection/http_urllib3.py", line 128, in perform_request
self._raise_error(response.status, raw_data)
File "/project/.env/lib/python3.5/site-packages/elasticsearch/connection/base.py", line 125, in _raise_error
raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.RequestError: <exception str() failed>

当我尝试手动发送请求时:

POST example.com:9200/twitter/_search?scroll=1m

{
"size": 100,
"query": {
"match_all": {}
}
}

它返回了我 100 个文档和 scroll_id。但这个 scroll_id 的长度是 524 个字符。也许这可能是一个问题。

最佳答案

我已经安装了最新的弹性包客户端。所以我从6.1.1降级到1.7.0

版本 1.7.0 中的 ElasticSearch 不支持 scroll id 的 POST 请求中的 JSON但较新的版本支持它。

关于python - helpers.scan() 不滚动 - ElasticSearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48244076/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com