# Best approach to find points within radius

**URL:** <https://discuss.elastic.co/t/best-approach-to-find-points-within-radius/36998>\
**Category:** Elasticsearch\
**Created:** [December 11, 2015, 3:49pm UTC](https://discuss.elastic.co/t/best-approach-to-find-points-within-radius/36998 "2015-12-11T15:49:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexey\_Danilov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexey_danilov/32/5995_2.png) [@Alexey\_Danilov](https://discuss.elastic.co/u/Alexey_Danilov)\
**Post date:** [December 11, 2015, 3:49pm UTC](https://discuss.elastic.co/t/best-approach-to-find-points-within-radius/36998/1 "2015-12-11T15:49:46Z")

</div>

Hi guys. I would like to get you insight on what is the best approach to use radius filtering - i.e. get points which are within a given range from the specified center.

In Java API there are two ways, based on the format in which points coordinates are stored.

1). Coordinate has a "geo\_point" mapping:  
"location": {  
"lat": -0.32005,  
"lon": 51.51321  
}

Then query will look like:  
QueryBuilder qb = QueryBuilders.geoDistanceQuery("location")  
.point(0.32003, 51.51328)  
.distance(1, DistanceUnit.KILOMETERS)  
.optimizeBbox("memory")  
.geoDistance(GeoDistance.SLOPPY\_ARC);

2). Coordinate has a "geo\_shape" mapping:  
"location": {  
"type": "point",  
"coordinates": [  
-0.32005,  
51.51321  
]  
}

Query will look like this:  
QueryBuilder qb = QueryBuilders.geoShapeQuery("location",  
ShapeBuilder.newCircleBuilder()  
.center(0.32003, 51.51328)  
.radius(1, DistanceUnit.KILOMETERS),  
ShapeRelation.WITHIN);

Both queries yield the same result. However, I am not sure which one is a recommended approach.

In my application one of the coordinates has to be geo\_shape - because I perform other geo shape queries on it (like find points within geo\_shape polygon). Now the question is, should I add another field for storing the same coordinates in geo\_point format (in addition to geo\_shape) - just for the sake of using geo distance query? Will it provide any performance benefits as compared to approach 2)?

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [December 11, 2015, 5:39pm UTC](https://discuss.elastic.co/t/best-approach-to-find-points-within-radius/36998/2 "2015-12-11T17:39:48Z")

</div>

Hi Alexey,

heres an older [forum thread](https://discuss.elastic.co/t/difference-between-geo-point-and-geo-shape-point/16477) pointing out some differences and tradeoffs between the two approaches. Not sure how much of this has changed in recent versions but as a starting point this might help.

---

<div class="post-metadata">

**Author:** ![Alexey\_Danilov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexey_danilov/32/5995_2.png) [@Alexey\_Danilov](https://discuss.elastic.co/u/Alexey_Danilov)\
**Post date:** [December 16, 2015, 10:20am UTC](https://discuss.elastic.co/t/best-approach-to-find-points-within-radius/36998/3 "2015-12-16T10:20:22Z")

</div>

Thanks a lot, Christoph!  
This link gave me the needed answer.

---

<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 5, 2017, 11:30pm UTC](https://discuss.elastic.co/t/best-approach-to-find-points-within-radius/36998/4 "2017-07-05T23:30:40Z")

</div>


