# Finding the closest geo\_point to a given one in 5.x

**URL:** <https://discuss.elastic.co/t/finding-the-closest-geo-point-to-a-given-one-in-5-x/71862>\
**Category:** Elasticsearch\
**Created:** [January 17, 2017, 1:13pm UTC](https://discuss.elastic.co/t/finding-the-closest-geo-point-to-a-given-one-in-5-x/71862 "2017-01-17T13:13:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mihai1voicescu](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@mihai1voicescu](https://discuss.elastic.co/u/mihai1voicescu)\
**Post date:** [January 17, 2017, 1:13pm UTC](https://discuss.elastic.co/t/finding-the-closest-geo-point-to-a-given-one-in-5-x/71862/1 "2017-01-17T13:13:05Z")

</div>

Because of the change to BKD trees for `geo_point` type, in order to **efficiently** find the closest point in a stored database to a given point a simple search with limit on size is enough?

```auto
GET geodatabase/location/_search
{
	sort: {
		_geo_distance: {
			coordinates: {
				lat: 23,
				lon: 23
			},
			order: "asc",
			unit: "km"
		}
	},
	size: 1
}

```

Previously we would also filter by `geohash_cell` with a precision of 5 and decrease it until a match was found.

---

<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:** [February 14, 2017, 1:13pm UTC](https://discuss.elastic.co/t/finding-the-closest-geo-point-to-a-given-one-in-5-x/71862/2 "2017-02-14T13:13:46Z")

</div>

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