Mapping a GeoPoint field
ElasticSearch natively supports the use of geolocation types—special types that allow localization of your document in geographic coordinate (latitude and longitude) around the world.
There are two main types used in the geographic world: the point and the shape. In this recipe we'll see the GeoPoint—the base element of a geolocation.
Getting ready
You need a working ElasticSearch cluster.
How to do it...
The type of the field must be set to geo_point
to define a GeoPoint.
We can extend the order example adding a new field that stores the location of a customer. The following code will be the result:
{ "order": { "properties": { "id": { "type": "string", "store": "yes", "index": "not_analyzed" }, "date": { "type": "date", "store": "no", "index": "not_analyzed" }, "customer_id": { "type": "string", "store": "yes", "index": "not_analyzed" }, "customer_ip": { "type": "ip...