Geo

Geo-bounding-box query

/ Geo, / Bounding_box, / Query

Geo-bounding-box query #

Matches documents whose geo_point field falls inside a rectangle defined by its top-left and bottom-right corners. Coordinates are WGS-84 degrees; filtering only (does not contribute distance scoring).

It is the cheapest geographic filter. When the region you need is a rectangle of latitude and longitude — a map viewport, a city’s extents, a country’s outline approximated by its bounds — the engine answers with a single index range and no per-document geometry math.

...

Geo-distance query

/ Geo, / Distance, / Query

Geo-distance query #

Matches documents whose geo_point field lies within a great-circle distance of a centre point. Distances are in metres.

This is the “find me things nearby” query: given one centre and one radius, it returns exactly the documents inside that disc on the sphere — the shape behind store locators, delivery zones and proximity alerts.

How it works #

The field is the same two-dimensional (lat, lon) BKD tree the other geo queries use (points indexed in any of the three ingest forms — object, [lon, lat] array, "lat,lon" string). Execution is two-phase:

...

Geo-polygon query

/ Geo, / Polygon, / Query

Geo-polygon query #

Matches documents whose geo_point field lies inside an arbitrary polygon. The ring is given as points in (lat, lon) order; vertices on the boundary count as inside, and holes can be modelled with a concave ring.

Real regions are rarely rectangular. City limits, districts, service areas and lakes have corners everywhere — this query filters points by an exact ring instead of the four edges of a bounding box.

...

Geo-shape query

/ Geo, / Shape, / Query

Geo-shape query #

Matches documents whose geo_shape field relates to a query geometry by a spatial relation. The query geometry is a GeoJSON geometry object or a WKT string; the indexed shape was written the same way.

Where the geo_point queries ask “is this point inside my region?”, geo_shape asks it of whole geometries — the document carries a polygon, line or envelope (a delivery zone, a pipeline route, a parcel) and the query tests it against another geometry.

...

Lesson 7 — Geographic search

/ Tutorial, / Geo

Lesson 7 — Geographic search #

From schema to data to queries: filter documents by where they are — a coordinate, a rectangle, an arbitrary polygon, or a full geometric shape.

Pizza has two geographic field types, and picking the right one is the whole design step:

  • geo_point — a single coordinate. Answers “where is this document?” Distance, box and polygon filters run against it.
  • geo_shape — a full geometry: point, line, polygon, multi-variant, envelope or geometry collection. Answers “what area does this document cover?” and supports the relation vocabulary (intersects, within, contains, disjoint).

A store is a geo_point; the district it serves is a geo_shape.

...