Spatial indexes

Wiki / Indexes and constraints

On this page

Point (spatial) index

An index over a Point property for bounded-distance and nearest queries.

From version 2.2.1 it orders points along a Z-order (Morton) curve built from their coordinates, so a query reads only the stretches of the index around its own area, whatever the unit or scale: metres, feet or degrees. withinDistance reads the box around the search circle and then checks each point's exact distance; for longitude and latitude the box follows the curve of the Earth, wraps across the 180th meridian and opens to every longitude near a pole. nearest widens its search until the k-th nearest point is inside it, so it reads the neighbourhood rather than the whole index. A database written by 2.0 to 2.2.0 rebuilds its point indexes in this layout when it opens.

Declare

CREATE POINT INDEX placeIdx FOR (n:Place) ON (n.loc);
SHOW POINT INDEXES;

Query

// everything within 5 km of a point, nearest first (metres for geographic SRIDs):
CALL db.index.geo.withinDistance('placeIdx', point({longitude: -0.12, latitude: 51.5}), 5000)
YIELD node, distance
RETURN node.name, distance ORDER BY distance;

// the 3 nearest places:
CALL db.index.geo.nearest('placeIdx', point({longitude: -0.12, latitude: 51.5}), 3)
YIELD node, distance
RETURN node.name, distance;

Removing the index

After querying, DROP POINT INDEX placeIdx removes the index; point properties remain.

Shape index

Updated 20 September 2026. WKB-backed geometry/geography properties use their own named spatial indexes:

CREATE SPATIAL INDEX regionShapes FOR (r:Region) ON (r.shape);
CALL db.index.spatial.intersects('regionShapes', spatial.fromWKT('POINT(2 2)'))
YIELD node
RETURN node.name;

This selects envelope candidates and then tests actual shape intersection. Domain, SRID and coordinate layout must match. Nonspatial properties are not indexed; empty shapes do not match. Legacy point() uses the POINT index above.

From version 2.2.0 the index is a multi-level grid. Each shape is filed once, under the cell at the level whose cells are at least as large as its bounding box, and a query reads only the cells around its own envelope, so its cost follows the shapes near it rather than the size of the index. Cell sizes follow the coordinates, so metres, feet and planar degrees need no configuration. When the query is an axis-aligned rectangle, every shape whose bounding box lies inside it matches without its geometry being decoded.

Geography envelopes follow great-circle edges: an edge's latitude range includes its bulge towards the pole, a shape across the antimeridian gets two envelopes, and a polygon around a pole reaches it on every longitude. Every envelope holds its whole shape, so the index never misses a match. WHERE spatial.intersects(...) does not automatically choose this index; request it through the procedure.

SHOW SPATIAL INDEXES lists declarations and DROP SPATIAL INDEX regionShapes removes one. Declarations persist across restarts and backfill existing data. Property/label changes, node deletion and transaction rollback update entries, and CALL gdb.compact() gives back the pages deleted shapes held. A database written by 2.0 to 2.1.8 rebuilds its shape indexes in the 2.2.0 layout when it opens. Index DDL is autocommit-only. See geometry and geography for valid inputs, storage upgrades and computational limits.

EXPLAIN and PROFILE · Resident and hybrid storage · Schema and maintenance procedures

Planning a deployment? Review compatibility and licence setup for your instance.