我正在使用Elasticsearch查询文档类型,该文档类型具有可选位置字段。搜索时,如果该字段不存在,应返回这些结果,并对结果进行过滤。在Elasticsearch可选字段上过滤
这似乎是OR过滤器Elasticsearch不会短路,因为这样:
"query": {
"filtered": {
"query": {
"match_phrase_prefix": {
"display_name": "SearchQuery"
}
},
"filter": {
"or": [
{
"missing": {
"field": "location"
}
},
{
"geo_distance" : {
"distance" : "20mi",
"location" : {
"lat" : 33.47,
"lon" : -112.07
}
}
}
]
}
无法与“未能找到geo_point场[位置]”。
是否有任何方法在ES中执行此操作(或沿着相同的静脉)?
谢谢,但仍然给我同样的错误。看起来它试图执行第二个条款,即使第一个条款匹配。 – Justin
https://www.elastic.co/guide/en/elasticsearch/guide/current/_dealing_with_null_values.html#_missing_query –