gpt4 book ai didi

用于 Elasticsearch 的 Python API - 每次响应 10000

转载 作者:行者123 更新时间:2023-12-03 01:22:44 24 4
gpt4 key购买 nike

client = Elasticsearch([host1, host2], http_auth=(user, password), scheme="http", port=port)
response = client.search(index="complats*", body={"from": 0, "size": 10000, "query": {
"bool": {
"must": [
{
"query_string": {
"query": "tags:\"prod\" AND severity:\"INFO\" AND service:\"abc-service\" AND msg:\"* is processed\"",
"fields": [],
"type": "best_fields",
"default_operator": "or",
"max_determinized_states": 10000,
"enable_position_increments": "true",
"fuzziness": "AUTO",
"fuzzy_prefix_length": 0,
"fuzzy_max_expansions": 50,
"phrase_slop": 0,
"escape": "false",
"auto_generate_synonyms_phrase_query": "true",
"fuzzy_transpositions": "true",
"boost": 1.0
}
},
{
"range": {
"@timestamp": {
"from": "now-{}s".format((now.minute + 1) * 60),
"to": "now",
"include_lower": "true",
"include_upper": "true",
"boost": 1.0
}
}
}
],
"adjust_pure_negative": "true",
"boost": 1.0
}
}})
value = response['hits']['total']['value']
print(value)

上述查询成功连接到elasticsearch,但每次都返回不正确的值或10000。这里有什么问题?我在某处读过python中的elasticsearch模块有一个错误,它的最大值为10000。还有其他人遇到过这个问题吗?如果是,你是如何解决的?
提前致谢!

最佳答案

它不是 python 库错误,不能返回超过 10000 个结果是从 lucene 继承的设置。如果您需要更多结果,您应该使用 search_after查询分页,或 scroll查询单个繁重的搜索,这取决于您的用例。看看我的回复here查看使用 python 实现这些查询的示例

关于用于 Elasticsearch 的 Python API - 每次响应 10000,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59503012/

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