bool query does not support [search_after] -- Elastic Search 错误
bool query does not support [search_after] -- Elastic Search error
我正在尝试查询我的索引并同时根据地理距离进行过滤,尽管通过我的索引进行分页,但我可能会收到此错误
错误:
{
"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
}
}
}
}
}
}
尝试从 query
中输入 search_after
:
{
"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"}
]
}
首先根据 date
和 tie_breaker_id
字段对文档进行排序,因此 "search_after": [1463538857, "654323"]
语句表示在日期 1463538857
和 tie_breaker_id "654323"
之后开始搜索
所以您在这里需要做的是根据某些字段对文档进行排序,然后提供 search_after 所需的值。
我正在尝试查询我的索引并同时根据地理距离进行过滤,尽管通过我的索引进行分页,但我可能会收到此错误
错误:
{
"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
}
}
}
}
}
}
尝试从 query
中输入 search_after
:
{
"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"}
]
}
首先根据 date
和 tie_breaker_id
字段对文档进行排序,因此 "search_after": [1463538857, "654323"]
语句表示在日期 1463538857
和 tie_breaker_id "654323"
之后开始搜索
所以您在这里需要做的是根据某些字段对文档进行排序,然后提供 search_after 所需的值。