How to find Retraurants in given longitude and latitude


(Jaychan) #1

HI,
Suppose I give assign id's to restraurant and want to get all the id's in given region when given longitude and latitude is given?Please find the below query and changes that need to be made.Thank you in advance.
GET /Restraurants/Grate_A/_search
{
"query" : {
"constant_score" : {
"filter" : {
"bool" : {
"should" : [
{ "term" : {"City" : "Dallas"}}
],
sort: {
_geo_distance: {
location: "#{80},#{180}",
order: "asc",
unit: "mi"
}

          }
       }

(Mark Walkom) #2

Does this not work?


(Jaychan) #3

No Bro,It is not working


(Makoto Nozawa) #4

Hi :raised_hand:

Maybe some JSON structure error.
how about this?

GET /Restraurants/Grate_A/_search
{
  "query": {
    "constant_score": {
      "filter": {
        "bool": {
          "should": [
            {
              "term": {
                "City": "Dallas"
              }
            }
          ]
        }
      }
    }
  },
  "sort": [
    {
      "_geo_distance": {
        "location": "#{80},#{180}",
        "order": "asc",
        "unit": "mi"
      }
    }
  ]
}

I created the query above by Console (Sence) but I don't have any data for it.
So please test it in your environment.

thanks.


(system) #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.