gpt4 book ai didi

Python Elasticsearch,RequestError : TransportError(400, u'search_phase_execution_exception') 间歇性发生。为什么?

转载 作者:行者123 更新时间:2023-11-28 17:31:11 27 4
gpt4 key购买 nike

我正在使用 Python Elasticsearch 在 elasticsearch (v. 1.7) 集群上运行基本过滤器。令人惊讶的是,我可以重复运行完全相同的代码,并以大约 1/2 的时间成功查询,并以大约 1/2 的时间收到 TransportError 400。我想知道这是我的语法原因还是我无法控制的原因。

from elasticsearch import Elasticsearch    
host_list = [HOST3, HOST4]
client = Elasticsearch(hosts = host_list, timeout = 120)
q = {"from" : 0,
"size" : 0,
"query": {
"filtered": {
"filter": {
"bool": {
"should": [
{"term": {
"field1": ["value1"]
}},
{"term": {
"field2": ["value2"]
}}
],
"must": [
{"range": {
"times": {
"gte": "2015-04-21T00:00:00Z",
"lte": "2015-04-22T00:00:00Z"
}
}}
]
}
}
}
}}
res = client.search(index = "index_name", doc_type = ("doc_type_name"), body = q)

返回

RequestError               Traceback (most recent call last)
--> 265 res = client.search(...)
(omitting long traceback through ES module code)
RequestError: TransportError(400, u'search_phase_execution_exception')

但另一半时间我得到的是有效结果?!有什么想法吗?

最佳答案

它可能是您的一位宿主已经死了。您应该尝试将 host_list 限制为 HOST3 并重试,然后将 host_list 限制为仅 HOST4 并重试。您会立即看到您的其中一台主机是否已关闭。

关于Python Elasticsearch,RequestError : TransportError(400, u'search_phase_execution_exception') 间歇性发生。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34227883/

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