- Elasticsearch 7.0 Cookbook(Fourth Edition)
- Alberto Paro
- 220字
- 2021-06-24 14:52:08
How it works...
When Elasticsearch indexes a document with a GeoPoint field (lat,lon), it processes the latitude and longitude coordinates and creates special accessory field data to provide faster query capabilities on these coordinates. This is because a special data structure is created to internally manage latitude and longitude.
Depending on properties, given a latitude and a longitude, it's possible to compute the geohash value (http://en.wikipedia.org/wiki/Geohash), and the index process also optimizes these values for special computation, such as distance, ranges, and in shape match.
GeoPoint has special parameters that allow you to store additional geographic data:
- lat_lon: This allows you to store the latitude and longitude as the .lat and .lon fields. Storing these values improves the performance in many memory algorithms used in distance and in shape calculus (false default).
It makes sense to set lat_lon to true so that you store them if there is a single point value for a field. This speeds up searches and reduces memory usage during computation.
- geohash: This allows you to store the computed geohash value (false default).
- geohash_precision: This defines the precision to be used in geohash calculus. For example, given a geo point value [45.61752, 9.08363], it will store the following (12 default):
- customer_location = 45.61752, 9.08363
- customer_location.lat = 45.61752
- customer_location.lon = 9.08363
- customer_location.geohash = u0n7w8qmrfj