# Sort and Filter by distance

**URL:** <https://discuss.elastic.co/t/sort-and-filter-by-distance/4919>\
**Category:** Elasticsearch\
**Created:** [July 21, 2011, 2:04pm UTC](https://discuss.elastic.co/t/sort-and-filter-by-distance/4919 "2011-07-21T14:04:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manish](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Manish](https://discuss.elastic.co/u/Manish)\
**Post date:** [July 21, 2011, 2:04pm UTC](https://discuss.elastic.co/t/sort-and-filter-by-distance/4919/1 "2011-07-21T14:04:25Z")

</div>

I have following restaurants in an index/type

{  
"restaurant" : {  
"id" : "1",  
"name" : "R1",  
"places" : [{ "location" : [24.897564,60.22326] },{ "location" :  
[24.91984,60.170425] },{ "location" : [24.911654,60.15944] },  
{ "location" : [24.91709,60.17587] } ],  
"tags" : ["chinese", "fastfood"]  
}  
}

{  
"restaurant" : {  
"id" : "2",  
"name" : "R2",  
"places" : [{ "location" : [24.911654,60.15944] },{ "location" :  
[24.96398,60.170563] }],  
"tags" : ["chinese", "fastfood", "cheap"]  
}  
}

{  
"restaurant" : {  
"id" : "3",  
"name" : "R3",  
"places" : [{ "location" : [24.913908,60.167263] },{ "location" :  
[24.897907,60.13356] }],  
"tags" : ["bar"]  
}  
}

{  
"restaurant" : {  
"id" : "4",  
"name" : "R4",  
"places" : [{ "location" : [24.925697,60.162685] }],  
"tags" : ["indian"]  
}  
}

{  
"restaurant" : {  
"id" : "5",  
"name" : "R5",  
"places" : [{ "location" : [24.939777,60.161095] }],  
"tags" : ["italian"]  
}  
}

I need a query to search for nearest two distinct restaurants from my  
current location: "lat" : 60.14727, "lon" : 24.89998.  
"location" is of type "geo\_point"  
One restaurant can be at multiple locations (think of Mc D)

---

<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:** [July 6, 2017, 3:59am UTC](https://discuss.elastic.co/t/sort-and-filter-by-distance/4919/2 "2017-07-06T03:59:54Z")

</div>


