Manish Kumar
Manish Kumar

Reputation: 10502

How to do geolocation search using Query String Query

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?

Upvotes: 3

Views: 493

Answers (1)

Sai Kiran
Sai Kiran

Reputation: 301

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.

Upvotes: 1

Related Questions