Location-Based Search
PostGIS-powered geospatial search with radius filtering, full-text indexing, and sub-second results. Find providers by location, keyword, or both.
Enterprise-Grade Search for Any Directory
Search is the core user experience of any directory. If a consumer searches “chiropractor near 90210” and gets irrelevant results or slow load times, they leave. AI Magic Directory delivers PostGIS-powered geospatial search that returns relevant, distance-sorted results in under 400 milliseconds.
Geospatial Search with PostGIS
Every listing location stores latitude and longitude coordinates with a PostGIS geography column. When a consumer searches, the platform:
- Geocodes their input (ZIP code, city name, or coordinates)
- Runs a spatial query with configurable radius (default: 25 miles)
- Calculates exact distance from the searcher to every matching provider
- Returns results sorted by distance, with featured/premium listings ranked first
This isn’t approximate. PostGIS uses the WGS84 geodetic model (the same one GPS satellites use) for meter-accurate distance calculations on the actual curved surface of the Earth.
Full-Text Search
Beyond location, consumers search by keyword — practice name, specialty, condition, service type. AI Magic Directory uses PostgreSQL’s native tsvector full-text search with automatic indexing:
- Multi-field indexing — Practice names, descriptions, and service tags are all indexed into a single search blob
- Relevance ranking — Results are ranked by text match quality, not just existence
- Fuzzy matching — The
pg_trgmextension enables typo-tolerant search (e.g., “chiropracter” still finds “chiropractor”) - Automatic updates — When a listing is modified, the search index updates automatically via database triggers
Combined Queries
The real power is combining geo and text search in a single query:
GET /api/listings?lat=34.05&lon=-118.24&radius=50&search=sports+medicine
This returns sports medicine providers within 50 miles of downtown Los Angeles, sorted by distance, with featured listings first. The query runs against spatial and text indexes simultaneously — no sequential scanning, no N+1 queries.
Performance at Scale
- Spatial indexes — GiST indexes on geography columns enable constant-time radius queries regardless of dataset size
- Text indexes — GIN indexes on tsvector columns handle full-text search in logarithmic time
- Response caching — API responses are cached for 300 seconds with
stale-while-revalidatefor 24 hours - Pagination — Configurable limit/offset with a maximum of 100 results per page to prevent payload bloat
- Load tested — k6 test suite validates p95 < 400ms under 25 concurrent users
Listing Detail Pages
Each listing gets a SEO-friendly detail page with:
- Practice name, description, website, and phone
- All locations with full addresses
- Service tags and specialties
- Lead capture form
- Custom meta title and description for search engine visibility
Distance Display
Search results show exact distance from the searcher (e.g., “3.2 miles away”), giving consumers confidence that the provider is genuinely local. This is calculated server-side from PostGIS, not estimated from ZIP code centroids.
Why This Matters for Revenue
Better search means higher conversion. When consumers find relevant, nearby providers quickly, they submit more leads. More leads mean more revenue — whether you’re billing per lead or charging subscription fees. PostGIS search isn’t a nice-to-have; it’s the revenue engine.
Ready to Launch Your Directory?
Get started today. Deploy your first directory and start generating revenue.