# Find the 100 closest neighbors to a point (lng, lat)

**URL:** <https://discuss.elastic.co/t/find-the-100-closest-neighbors-to-a-point-lng-lat/20418>\
**Category:** Elasticsearch\
**Created:** [October 24, 2014, 9:11am UTC](https://discuss.elastic.co/t/find-the-100-closest-neighbors-to-a-point-lng-lat/20418 "2014-10-24T09:11:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Lumbroso](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@Michael\_Lumbroso](https://discuss.elastic.co/u/Michael_Lumbroso)\
**Post date:** [October 24, 2014, 9:11am UTC](https://discuss.elastic.co/t/find-the-100-closest-neighbors-to-a-point-lng-lat/20418/1 "2014-10-24T09:11:24Z")

</div>

Hello,

sorry if this question has already been asked, but I didn't find much  
material during my search.  
Basically, what I need to do, is find the exact 100 closest objects around  
a spatial point (longitude, latitude), among a 1 million geolocalized  
object all around the world.

Is there an efficient way to do that? (performance is the most important  
parameter here)  
Are there plugins/libraries to help me do so?  
Are there better options than Elasticsearch for this very problem?

Thanks for your help, and keep up the good work on this wonderful tool

Michael

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/04ce1fbd-c88f-4517-9d56-044bb235c29c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/04ce1fbd-c88f-4517-9d56-044bb235c29c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [October 27, 2014, 5:27pm UTC](https://discuss.elastic.co/t/find-the-100-closest-neighbors-to-a-point-lng-lat/20418/2 "2014-10-27T17:27:32Z")

</div>

Hi Michael,

You can do that using geo-distance sorting:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

It would probably not be optimal in the sense that elasticsearch will need  
to compute the distance for every matching document, but maybe it would  
still be fast enough?

On Fri, Oct 24, 2014 at 11:11 AM, Michael Lumbroso [michael@sportintown.com](mailto:michael@sportintown.com)  
wrote:

> Hello,
> 
> sorry if this question has already been asked, but I didn't find much  
> material during my search.  
> Basically, what I need to do, is find the exact 100 closest objects around  
> a spatial point (longitude, latitude), among a 1 million geolocalized  
> object all around the world.
> 
> Is there an efficient way to do that? (performance is the most important  
> parameter here)  
> Are there plugins/libraries to help me do so?  
> Are there better options than Elasticsearch for this very problem?
> 
> Thanks for your help, and keep up the good work on this wonderful tool
> 
> Michael
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/04ce1fbd-c88f-4517-9d56-044bb235c29c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/04ce1fbd-c88f-4517-9d56-044bb235c29c%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/04ce1fbd-c88f-4517-9d56-044bb235c29c%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/04ce1fbd-c88f-4517-9d56-044bb235c29c%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j45xYH%2BGmF%2BQ3t5m1OYLKZD7Vp6p0HxpmkD7-Q%2B7Zu1hQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j45xYH%2BGmF%2BQ3t5m1OYLKZD7Vp6p0HxpmkD7-Q%2B7Zu1hQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Michael\_Lumbroso](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@Michael\_Lumbroso](https://discuss.elastic.co/u/Michael_Lumbroso)\
**Post date:** [October 28, 2014, 9:08am UTC](https://discuss.elastic.co/t/find-the-100-closest-neighbors-to-a-point-lng-lat/20418/3 "2014-10-28T09:08:08Z")

</div>

Hi Adrien,

thanks for your answer, but actually, I need something really optimized, so  
I guess ES is not the way to go.

Can you think of better ways to actually do that?

Thanks

2014-10-27 18:27 GMT+01:00 Adrien Grand [adrien.grand@elasticsearch.com](mailto:adrien.grand@elasticsearch.com):

> Hi Michael,
> 
> You can do that using geo-distance sorting:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#_geo_distance_sorting)
> 
> It would probably not be optimal in the sense that elasticsearch will need  
> to compute the distance for every matching document, but maybe it would  
> still be fast enough?
> 
> On Fri, Oct 24, 2014 at 11:11 AM, Michael Lumbroso \<  
> [michael@sportintown.com](mailto:michael@sportintown.com)\> wrote:
> 
> > Hello,
> > 
> > sorry if this question has already been asked, but I didn't find much  
> > material during my search.  
> > Basically, what I need to do, is find the exact 100 closest objects  
> > around a spatial point (longitude, latitude), among a 1 million  
> > geolocalized object all around the world.
> > 
> > Is there an efficient way to do that? (performance is the most important  
> > parameter here)  
> > Are there plugins/libraries to help me do so?  
> > Are there better options than Elasticsearch for this very problem?
> > 
> > Thanks for your help, and keep up the good work on this wonderful tool
> > 
> > Michael
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/04ce1fbd-c88f-4517-9d56-044bb235c29c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/04ce1fbd-c88f-4517-9d56-044bb235c29c%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/04ce1fbd-c88f-4517-9d56-044bb235c29c%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/04ce1fbd-c88f-4517-9d56-044bb235c29c%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> Adrien Grand
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/aWZBVkZiSY4/unsubscribe](https://groups.google.com/d/topic/elasticsearch/aWZBVkZiSY4/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j45xYH%2BGmF%2BQ3t5m1OYLKZD7Vp6p0HxpmkD7-Q%2B7Zu1hQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j45xYH%2BGmF%2BQ3t5m1OYLKZD7Vp6p0HxpmkD7-Q%2B7Zu1hQ%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j45xYH%2BGmF%2BQ3t5m1OYLKZD7Vp6p0HxpmkD7-Q%2B7Zu1hQ%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j45xYH%2BGmF%2BQ3t5m1OYLKZD7Vp6p0HxpmkD7-Q%2B7Zu1hQ%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAH-zEnNoh%2BTysKSiX7y67M6HyFE60cEnYhf6DWSQoCu\_5jtRdQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAH-zEnNoh%2BTysKSiX7y67M6HyFE60cEnYhf6DWSQoCu_5jtRdQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Michael\_Lumbroso](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@Michael\_Lumbroso](https://discuss.elastic.co/u/Michael_Lumbroso)\
**Post date:** [November 3, 2014, 2:04pm UTC](https://discuss.elastic.co/t/find-the-100-closest-neighbors-to-a-point-lng-lat/20418/4 "2014-11-03T14:04:16Z")

</div>

Anyone has an idea on which tool is the best to perform this task? This  
would be of a major help 🙂

Thanks for your answers!

Le vendredi 24 octobre 2014 11:11:24 UTC+2, Michael Lumbroso a écrit :

> Hello,
> 
> sorry if this question has already been asked, but I didn't find much  
> material during my search.  
> Basically, what I need to do, is find the exact 100 closest objects around  
> a spatial point (longitude, latitude), among a 1 million geolocalized  
> object all around the world.
> 
> Is there an efficient way to do that? (performance is the most important  
> parameter here)  
> Are there plugins/libraries to help me do so?  
> Are there better options than Elasticsearch for this very problem?
> 
> Thanks for your help, and keep up the good work on this wonderful tool
> 
> Michael

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6e2d21bc-3a38-4174-ba1a-3e4dfa3e6e17%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6e2d21bc-3a38-4174-ba1a-3e4dfa3e6e17%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:52am UTC](https://discuss.elastic.co/t/find-the-100-closest-neighbors-to-a-point-lng-lat/20418/5 "2017-07-06T00:52:29Z")

</div>


