我想{ "query" : { "match_all" :{}}}对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进行过滤,则可以使用…任何帮助都将是极好的。
"and" :{}
干杯
我认为您的and过滤器写有误。该错误表明and过滤器或多或少地在参数方面遇到问题。参见http://www.elasticsearch.org/guide/reference/query- dsl/and-filter/
and
尝试以下方法:
{ "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" } } ] }