liveBook · Manning

Geo_point data type

As explained in Elasticsearch in Action, Second Edition

A geographic coordinate represented by a latitude and longitude pair.

A geo_point stores a location as longitude and latitude so Elasticsearch can index places such as restaurants, schools, bus stops, and houses for location-based search. section 4.6.1 section 12.1

Map a restaurant address

Define the location field as geo_point, then index coordinates for a restaurant. The object form uses lon and lat fields. section 4.6.1

Listing 4.20 Mapping schema with a field declared as a geo_point type
PUT restaurants
{
  "mappings": {
    "properties": {
      "name":{
        "type": "text"
      },
      "address":{
        "type": "geo_point"
      }
    }
  }
}

Use the mapping listing as a minimal starting point: declare address as geo_point alongside the restaurant name. section 4.6.1

After mapping, search geo_point fields with geospatial queries. A geo_bounding_box query uses top_left and bottom_right geopoints to select documents inside a rectangle; ensure their coordinates form the intended box. section 4.6.1 section 12.3

Table 4.3 Location information-related formats (view table figure)

Format

Explanation

Example

Array

Geopoint represented as an array. Note the order of the geopoint inputs: it takes lon and lat, not the other way around (unlike the string format—see the next row).

"address":[0.12,51.5]

String

Geopoint as string data with lat and lon inputs.

"address":"51.5,0.12"

Geohash

An encoded string formed by hashing the longitude and latitude coordinates. The alphanumeric string points to a place on earth.

u10j4

Point

A precise location on a map. Known as well-known text (WKT), a standard mechanism to represent geometrical data.

POINT(51.5,-0.12)

Compare supported input formats before indexing: object, array, string, geohash, and WKT POINT. Coordinate order varies by format, so follow each format's convention. section 4.6.1 section 12.2.1

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Defines mappings, indexes several coordinate formats, and demonstrates geo_bounding_box search while deferring detailed geo-query treatment.
Examples
Uses London restaurants and bus stops, including Sticky Fingers, London Bridge Station, and multiple coordinate representations.
What it assumes
Assumes basic Elasticsearch mappings and indexing, while introducing longitude, latitude, geopoints, and location-based search.
What you can do after
Build it from scratch by mapping geo_point fields, indexing locations, and applying a geo_bounding_box query.
How it connects
Connects geo_point with mappings, geospatial queries, geo_bounding_box, geo_distance, and the contrasting geo_shape type.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elasticsearch in Action, Second Edition. The section links point to the parts of the book it draws on.