2017-04-07 69 views
0

这可能很简单,但我无法实现或找出预期的查询格式。在elasticsearch中使用多个geopoints过滤

我能够从我的应用程序中创建geo_point数据类型的映射。我还可以通过发送下面的查询请求主体的一部分,用来查询与GeoPoint的指标:

{ 
    "query": { 
     "bool" : { 
      "must" : { 
       "match_all" : {} 
      }, 
      "filter" : { 
       "geo_distance" : { 
        "distance" : "5km", 
        "field_location" : "9.0194,-79.4509" 
       } 
      } 
     } 
    } 
} 

这里,field_location是为geo_point类型的字段的名称。这工作非常好。

我无法找到一种方法,我可以向筛选器提供多个lat/lon值,并在它们之间使用OR。我试图在查询中使用SHOULD,但无法找到正确的方法。任何关于如何实现这一点的指针都会非常有帮助。

回答

0

看来我在正确的道路上。 elasticsearch的Bool query支持运营商。我只是没有正确使用它。

下面的查询工作:

{ 
    "query": { 
     "bool": { 
      "should": [ 
       { 
        "geo_distance": { 
         "distance": "1km", 
         "field_location": "9.0194,-79.4509" 
        } 
       }, 
       { 
        "geo_distance": { 
         "distance": "1km", 
         "field_location": "8.9972,-79.4985" 
        } 
       } 
      ] 
     } 
    } 
} 
相关问题