Geo radius query
Find documents within a radius of a point and combine the geo filter with a text
query. Coordinates are (longitude, latitude), the same order GeoJSON uses and the
opposite of how most map UIs show them.
import sasvi
from sasvi.search import F
client = sasvi.SVIClient.from_env()
results = (
client.search
.types("Incident")
.text("flood") # safe-by-default; escapes Lucene
.filter(
F.geo_radius(
center=(-74.0060, 40.7128), # NYC: (lng, lat)
radius="10km",
)
)
.summary(limit=50)
)
for hit in results:
print(hit["display_label"], hit.get("location"))
F.geo_radius accepts:
center:(longitude, latitude)tuple.radius: SAND-format radius string ("10km","5mi","500m").
SAND geo filters run against the entity type's canonical geo field. There is no
per-call field= parameter.
Polygon and box
F.geo_polygon(
(-74.01, 40.70),
(-74.01, 40.73),
(-73.97, 40.73),
(-73.97, 40.70),
)
F.geo_box(
top_left=(-74.01, 40.73),
bottom_right=(-73.97, 40.70),
)
Each point in geo_polygon is (lng, lat). geo_box corners are the same.
Geo shape with a stored shape id
For SAND-stored shapes managed through client.admin.shapes:
F.geo_shape(id="<shape-id>", relation="within")
relation is one of "contains", "disjoint", "intersects", "within" (the
GeoRelation type alias).
Common mistakes
| Symptom | Likely cause | Fix |
|---|---|---|
0 results for a known-good point | Coordinates passed as (lat, lng) | Swap to (lng, lat) |
InvalidSearchQueryError | Radius unit not recognized | Use m, km, mi, ft |
| Field not in scope | The entity type has no canonical geo field configured | Configure the geo field on the entity type in VI admin |
Go further
- Search DSL reference. Every operator.
- Shapes guide. Managing stored shapes through
client.admin.shapes.