gpt4 book ai didi

Elasticsearch:无法过滤多个字段

转载 作者:行者123 更新时间:2023-12-03 16:19:28 24 4
gpt4 key购买 nike

我想在 elasticsearch 上过滤一个 { "query": { "match_all":{}}} 但我不知道...

这是我发送给 ES _search 方法的内容。

curl -XGET http://localhost:9200/users/location/_search '-H Accept: application/json' '-H Content-Type: application/json'
-d '{
"query":{
"match_all":{}
},
"filter":{
"and":{
"geo_distance":{
"distance":"500km",
"location":{
"lat":48.8,
"lon":2.33
}
},
"term":{
"status":1
}
}
},
"sort":[
{
"_geo_distance":{
"location":[
2.33,
48.8
],
"order":"asc",
"unit":"km"
}
}
]
}'

但我总是得到这个错误:

nested: QueryParsingException[[users] [and] filter does not support [distance]]

如果我删除 "and":{} 选项并仅根据 geo_distance 进行过滤,它会起作用...任何帮助都会很棒。

干杯

最佳答案

我认为您的 过滤器写错了。该错误表明 过滤器或多或少在参数方面存在问题。参见 http://www.elasticsearch.org/guide/reference/query-dsl/and-filter/

试试这个:

{
"query":{
"match_all":{}
},
"filter":{
"and": [
{
"geo_distance": {
"distance":"500km",
"location":{
"lat":48.8,
"lon":2.33
}
}
}, {
"term": {
"status":1
}
}]
}
},
"sort":[
{
"_geo_distance":{
"location":[
2.33,
48.8
],
"order":"asc",
"unit":"km"
}
}
]
}

关于Elasticsearch:无法过滤多个字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18921903/

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