liveBook · Manning

Geospatial query

As explained in Elasticsearch in Action, Second Edition

Geospatial search retrieves data according to geographic locations, shapes, distances, or spatial relationships.

Geospatial queries retrieve places according to coordinates, distances, areas, or spatial relationships. They support practical searches such as nearby restaurants, homes within a radius, directions, and points of interest in an area. section 12.0 section 12.1

Elasticsearch indexes location data with geo_point for individual coordinates and geo_shape for areas or other two-dimensional shapes. Queries then compare documents with points, rectangles, distances, or shapes. section 12.1 section 12.3

Choose a query according to the spatial condition:

  • geo_bounding_box finds documents inside a rectangle defined by geopoints. section 12.3
  • geo_distance finds addresses or other documents within a specified distance from a point. section 12.3
  • geo_shape finds documents whose shapes satisfy a relationship with a shape constructed from coordinates. section 12.3

Nearby ATMs

A location search can use geo_distance to find all ATMs within 1 km of London Bridge. The same approach supports nearby restaurants, houses within a radius, or other proximity-based results. section 12.1 section 12.3

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Explains geo_point and geo_shape data types and distinguishes bounding-box, distance, and shape queries.
Examples
Uses restaurants, ATMs near London Bridge, homes within a radius, farms, green belts, and school playgrounds.
What you can do after
Apply it via Elasticsearch to search indexed points or shapes by proximity, containment, rectangles, or spatial relationships.
How it connects
Connects geo_point and geo_shape fields with geo_bounding_box, geo_distance, and geo_shape queries.

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.