我想过滤一下 { "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"
}
}
]
}'
Run Code Online (Sandbox Code Playgroud)
但我总是得到这个错误:
nested: QueryParsingException[[users] [and] filter does not support [distance]]
Run Code Online (Sandbox Code Playgroud)
如果我删除该"and" :{}选项并仅对geo_distance进行过滤,则可以正常工作......任何帮助都会非常棒.
干杯
我认为您的and过滤器写得不正确.该错误表明and过滤器的参数有问题,或多或少.见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"
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7359 次 |
| 最近记录: |