Spatial Index
← Back to DP-420 Terminology Reference
Category: Optimization
Summary: Accelerates geospatial queries (ST_DISTANCE, ST_WITHIN) over GeoJSON properties.
Overview
A spatial index supports efficient execution of geospatial queries — such as ST_DISTANCE, ST_WITHIN, and ST_INTERSECTS — over properties containing GeoJSON data (e.g., Point, Polygon, LineString). Spatial indexes are applied automatically to properties recognized as GeoJSON when using the default indexing policy, enabling location-based queries like 'find all items within X kilometers of a point'.
More Info & Links
DP-420 Style Practice Questions
Q1. What kind of queries does a spatial index accelerate in Azure Cosmos DB?
- A. Geospatial queries such as proximity (ST_DISTANCE) and containment (ST_WITHIN) over GeoJSON data
- B. Full-text search queries
- C. Vector similarity search queries
- D. Aggregate queries such as COUNT and SUM
Q2. What data format must a property use to benefit from a spatial index?
- A. GeoJSON (e.g., Point, Polygon, LineString)
- B. XML
- C. A composite of two numeric properties
- D. A base64-encoded binary blob
Answer Key
Answers are listed at the very end so you can attempt the questions first.
- Q1 (Spatial Index): A. Geospatial queries such as proximity (ST_DISTANCE) and containment (ST_WITHIN) over GeoJSON data — Spatial indexes accelerate geospatial functions like ST_DISTANCE, ST_WITHIN, and ST_INTERSECTS over GeoJSON properties.
- Q2 (Spatial Index): A. GeoJSON (e.g., Point, Polygon, LineString) — Spatial indexes apply to properties containing valid GeoJSON data types such as Point, Polygon, and LineString.
DP-420: Designing and Implementing Cloud-Native Applications Using Microsoft Azure Cosmos DB — term detail page