How to do geolocation search using Query String Qu

2019-07-09 04:11发布

I was going through Query String Query https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html

How can i do geo location based search if i have latitude and longitude and range in KM?

1条回答
小情绪 Triste *
2楼-- · 2019-07-09 04:35

After some experiments and some search on net. I achieved this with wrapping "query string" in bool query.

{
 "size": 0,
 "query": {
   "bool": {
     "must": {
       "query_string": {
         "query": "one:1 AND two:2"
       }
     },
     "filter": {
       "geo_distance": {
         "distance": "12km",
         "latLong": "16.48,80.61"
       }
     }
   }
 },
 "from": "0",
 "_source": [
   "user"
 ]
}

cheers.

Thank-you.

查看更多
登录 后发表回答