Geographic filter for location-based searches.
Geo fields in Redis support radius-based geographic queries. They store coordinates as longitude,latitude pairs and allow filtering based on distance from a point.
Geo fields must be indexed with the GEO type in the metadata schema. Coordinates should be stored as "longitude,latitude" strings or [lon, lat] arrays.
class GeoFilterDiscriminator property for type-safe filter identification. Each filter type has a unique filterType value.
Combine this filter with another using AND logic.
In RediSearch, AND operations are represented by space-separated conditions
within parentheses: (condition1 condition2)
Combine this filter with another using OR logic.
In RediSearch, OR operations are represented by pipe-separated conditions
within parentheses: (condition1|condition2)
Converts the filter expression to a RediSearch query string.
Creates a builder object for constructing geographic filters.
// Find locations within 10km of San Francisco
const filter = new GeoFilter("location", -122.4194, 37.7749, 10, "km");
// Generates: @location:[-122.4194 37.7749 10 km]
// Find locations within 5 miles of New York
const filter = new GeoFilter("store_location", -74.0060, 40.7128, 5, "mi");
// Generates: @store_location:[-74.0060 40.7128 5 mi]
// Find locations outside a radius (negation)
const filter = new GeoFilter("location", -122.4194, 37.7749, 50, "km", true);
// Generates: (-@location:[-122.4194 37.7749 50 km])
// Using convenience methods
const filter = Geo("location").within(-122.4194, 37.7749, 10, "km");
const filter2 = Geo("location").outside(-74.0060, 40.7128, 100, "mi");