# How to find Retraurants in given longitude and latitude

**URL:** <https://discuss.elastic.co/t/how-to-find-retraurants-in-given-longitude-and-latitude/72697>\
**Category:** Elasticsearch\
**Created:** [January 24, 2017, 8:43pm UTC](https://discuss.elastic.co/t/how-to-find-retraurants-in-given-longitude-and-latitude/72697 "2017-01-24T20:43:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ja\_chan](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@ja\_chan](https://discuss.elastic.co/u/ja_chan)\
**Post date:** [January 24, 2017, 8:43pm UTC](https://discuss.elastic.co/t/how-to-find-retraurants-in-given-longitude-and-latitude/72697/1 "2017-01-24T20:43:51Z")

</div>

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"  
}

```
          }
       }
```

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 29, 2017, 8:24am UTC](https://discuss.elastic.co/t/how-to-find-retraurants-in-given-longitude-and-latitude/72697/2 "2017-01-29T08:24:21Z")

</div>

Does this not work?

---

<div class="post-metadata">

**Author:** ![ja\_chan](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@ja\_chan](https://discuss.elastic.co/u/ja_chan)\
**Post date:** [January 31, 2017, 8:55pm UTC](https://discuss.elastic.co/t/how-to-find-retraurants-in-given-longitude-and-latitude/72697/3 "2017-01-31T20:55:45Z")

</div>

No Bro,It is not working

---

<div class="post-metadata">

**Author:** ![mnozawa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mnozawa/32/15091_2.png) [@mnozawa](https://discuss.elastic.co/u/mnozawa)\
**Post date:** [February 1, 2017, 5:13am UTC](https://discuss.elastic.co/t/how-to-find-retraurants-in-given-longitude-and-latitude/72697/4 "2017-02-01T05:13:36Z")

</div>

Hi ✋

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 1, 2017, 5:13am UTC](https://discuss.elastic.co/t/how-to-find-retraurants-in-given-longitude-and-latitude/72697/5 "2017-03-01T05:13:51Z")

</div>

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