gpt4 book ai didi

elasticsearch - bool查询不支持[search_after]- Elasticsearch 错误

转载 作者:行者123 更新时间:2023-12-03 02:30:45 26 4
gpt4 key购买 nike

我试图通过索引索引同时查询我的索引并根据地理距离进行过滤,但我可能会收到此错误

错误:

{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "bool query does not support [search_after]",
"line": 7,
"col": 21
}
],
"type": "parsing_exception",
"reason": "bool query does not support [search_after]",
"line": 7,
"col": 21
},
"status": 400
}

实际查询:
{
"query": {
"bool" : {
"should" : {
"match_all" : {}
},
"search_after": [1463538857, "654323"],
"filter" : {
"geo_distance" : {
"distance" : "150km",
"location" : {
"lat" : xxxx,
"lon" : xxxxx
}
}
}
}
}
}

最佳答案

尝试将search_after放在query之外:

{
"query": {
"bool" : {
"should" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "150km",
"location" : {
"lat" : xxxx,
"lon" : xxxxx
}
}
}
}
}
search_after": [1463538857, "654323"]
}

因此,顾名思义, search_after将在给定值后开始匹配。您需要为此指定一些顺序。例如在 documentation的示例中
GET twitter/_search
{
"size": 10,
"query": {
"match" : {
"title" : "elasticsearch"
}
},
"search_after": [1463538857, "654323"],
"sort": [
{"date": "asc"},
{"tie_breaker_id": "asc"}
]
}

首先根据 datetie_breaker_id字段对文档进行排序,因此 "search_after": [1463538857, "654323"]语句意味着在日期 1463538857和tie_breaker_id "654323"之后开始搜索

因此,您需要在此处基于某些字段对文档进行排序,然后为search_after提供所需的值。

关于elasticsearch - bool查询不支持[search_after]- Elasticsearch 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60062714/

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