Mapping a geo point field

ElasticSearch natively supports the use of geolocation types: special types that allow you to localize your document in geographic coordinates (latitude and longitude) around the world.

There are two main document types used in the geographic world: point and shape. In this recipe, we'll see geo point, the base element of geolocation.

Getting ready

You need a working ElasticSearch cluster.

How to do it...

The type of the field must be set to geo_point in order to define a geo point.

You can extend the earlier order example by adding a new field that stores the location of a customer. The following will be the result:

{ "order": { "properties": { "id": { "type": "string", "store": "yes", "index": "not_analyzed" }, "date": { ...

Get ElasticSearch Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.