> Markdown version of [/videos/77-add-location-based-searching-to-site-with-elasticsearch](https://www.wearedevelopers.com/videos/77-add-location-based-searching-to-site-with-elasticsearch). Every page supports `.md` or `Accept: text/markdown`. Links point to the HTML versions so they work for humans too. Agent guide: [/agents.md](https://www.wearedevelopers.com/agents.md). --- # Add Location-based Searching to Site with ElasticSearch How do you return localized search results across millions of records in mere milliseconds? Discover how to combine geographic boolean filters with ranked text queries in Elasticsearch. - **Speakers:** Derek Binkley - **Event:** WeAreDevelopers LIVE - **Published:** November 30, 2020 - **Duration:** 45:13 - **URL:** https://www.wearedevelopers.com/videos/77-add-location-based-searching-to-site-with-elasticsearch ## Summary Elasticsearch serves as a highly efficient, read-optimized engine designed for bringing rapid location-based and text search capabilities to modern site backends. Operating seamlessly via REST API calls and JSON documents, it eliminates the need to learn proprietary query languages. Leveraging tools like Kibana from the broader ELK stack alongside Docker environments simplifies the development process, allowing engineers to incrementally design and test queries with immediate feedback and syntax highlighting. <br/><br/> A robust Elasticsearch implementation pairs precise data mapping with an understanding of internal search mechanics. Distinguishing between `text` fields for fuzzy language matching and `keyword` fields for exact, categorical lookups ensures accurate filtering without unnecessary processing overhead. Specialized spatial formats, particularly mapping latitude and longitude to `geo_point` or boundaries to `geo_shape`, lay the groundwork for advanced geospatial use cases. Furthermore, adopting bulk ingestion strategies over transactional, single-record database inserts optimizes performance and matches the platform's read-first architecture. <br/><br/> The real power of the system surfaces when blending boolean spatial filters with ranked text searches. Developers can craft queries that define a precise geographic radius, calculate real-world distances accounting for Earth's curvature, or restrict findings to custom polygon bounding boxes. By executing a strict yes-or-no geographic filter before scoring text relevancy, the engine can confidently return localized results across millions of records in mere milliseconds. Coupled with a flexible mapping mechanism that gracefully integrates nested schema objects, Elasticsearch provides an adaptable, high-performance foundation for location-aware applications. **Keywords:** location-based search API, elasticsearch REST queries, apache lucene indexing, kibana visual dashboards, geo_point data types, geo_shape polygon search, boolean filter operations, text relevance scoring, geographic distance sorting, bulk data ingestion, read-optimized data store, spatial proximity filtering, geospatial bounding boxes, nested object mapping ## Chapters 1. **Understanding the fundamentals of the Elasticsearch engine** (00:17) — A look at Elasticsearch as a read-optimized, REST-based search engine built on Apache Lucene. 1. **Exploring the core components of the ELK stack** (02:52) — How Beats, Logstash, Kibana, and Elasticsearch work together for managing and visualizing data. 1. **Reviewing deployment and hosting options for Elasticsearch clusters** (04:23) — Different environments for running search clusters including AWS images, Docker containers, and GraphQL annotation integrations. 1. **Bootstrapping the geographic location API using Docker Compose** (05:45) — How to spin up an Elasticsearch and Kibana instance locally using a Docker compose file. 1. **Defining indexes and documents in the Elasticsearch data structure** (08:02) — The hierarchy of indices, document types, and mappings used to structure saved records. 1. **Configuring property mappings and spatial data types for indexing** (09:15) — How to configure schema templates that support integer, text, keyword, and geospatial data points. 1. **Reviewing the geographic feature classes inside the sample dataset** (13:44) — A brief look at the format of location records grouped by feature classes and codes. 1. **Executing simple full-text search queries using the Kibana interface** (14:35) — Running raw queries to rapidly analyze large numbers of documents based on a matched search score. 1. **Filtering query outputs and structuring complex boolean search requests** (19:27) — Applying keyword filters alongside fuzzy matching to exclude irrelevant documents without affecting relevancy scores. 1. **Grouping distinct dataset values using Elasticsearch bucket aggregation queries** (23:38) — How bucket aggregations behave like database groupings to isolate distinct properties for exploration. 1. **Leveraging native search functions like the more like this feature** (24:42) — Exploring native performance boosts and feature behaviors like retrieving similar records to help discover nested items. 1. **Optimizing index data ingestion using bulk insert operations** (26:02) — Preparing chunked data payloads in PHP to optimize the speed of ingesting large quantities of records. 1. **Outlining the architecture needed for geographic distance search operations** (27:48) — The basic goals of querying mapping endpoints via latitude, longitude, and custom spatial radii. 1. **Restricting search locations matching a radial geographic distance query** (29:08) — Applying a spatial radius filter around a specific coordinate to precisely constrain matching query responses. 1. **Chaining full-text string matching algorithms with strict geospatial filters** (32:01) — Unifying string matching behaviors with a coordinate distance boundary using a boolean combined query pattern. 1. **Sorting matched coordinate search results by accurate geographical distances** (35:17) — Arranging the final search payloads geographically and customizing mathematical plane algorithms to evaluate distance spans. 1. **Constraining geographic record sets using map bounds and polygons** (40:24) — Drawing custom map boxes or custom polygon shapes to strictly bind valid matching results. 1. **Updating dynamic schema mappings to support nested data arrays** (42:52) — Modifying schemas dynamically to append new metadata fields like arrays of nested location comments. ## Related Moments - [Core search and resiliency capabilities of Elasticsearch](https://www.wearedevelopers.com/videos/256-distributed-search-under-the-hood) (from "Distributed search under the hood") - [Managing geospatial queries and analytical endpoints with Redis](https://www.wearedevelopers.com/videos/337-covid-19-a-crowdsourced-map-for-checking-supermarket-wait-times-worldwide) (from "Covid-19 - A crowdsourced map for checking supermarket wait times worldwide") - [Audience Q&A on data formats and engine tradeoffs](https://www.wearedevelopers.com/videos/100075-parquet-delta-iceberg-ducklake-an-introduction-for-developers) (from "Parquet, Delta, Iceberg & Ducklake - An introduction for developers") - [Utilizing Elasticsearch infrastructure as a vector database](https://www.wearedevelopers.com/videos/860-harry-potter-and-the-elastic-semantic-search) (from "Harry Potter and the Elastic Semantic Search") - [Core architecture and federated execution of SearchOLAP](https://www.wearedevelopers.com/videos/100212-olap-for-ai-applications-and-why-you-should-care) (from "OLAP for AI Applications and why you should care") - [Core OpenSearch cluster architecture and terminology](https://www.wearedevelopers.com/videos/490-search-and-aggregations-made-easy-with-opensearch-and-nodejs) (from "Search and aggregations made easy with OpenSearch and NodeJS") ## Related Articles - [SEO in an AI world - Google vs. ChatGPT and survival tips for content creators](https://www.wearedevelopers.com/magazine/534-seo-in-an-ai-world-google-vs-chatgpt-and-survival-tips-for-content-creators) - [Making Data Warehouses Fast: A Developer’s Story](https://www.wearedevelopers.com/magazine/107-making-data-warehouses-fast-a-developer-s-story) - [WeAreDevelopers Dev Digest Issue 116 - The new search wars…](https://www.wearedevelopers.com/magazine/445-wearedevelopers-dev-digest-issue-116-the-new-search-wars) - [Dev Digest 139 - Soft and hard queries](https://www.wearedevelopers.com/magazine/487-dev-digest-139-soft-and-hard-queries) ## Related Jobs - [Principal Engineer - AI Search & Vector Infrastructure](https://www.wearedevelopers.com/jobs/ext/319507-principal-engineer-ai-search-vector-infrastructure) at **Redis** - [Principal Engineer - AI Search & Vector Infrastructure](https://www.wearedevelopers.com/jobs/ext/353953-principal-engineer-ai-search-vector-infrastructure) at **Redis** - [Principal Engineer - AI Search & Vector Infrastructure](https://www.wearedevelopers.com/jobs/ext/381484-principal-engineer-ai-search-vector-infrastructure) at **Redis** - [Senior Software Engineer, Data](https://www.wearedevelopers.com/jobs/48273-senior-software-engineer-data) at **Sportradar Media Services GmbH** - [Lead Software Engineer - Data Engineering](https://www.wearedevelopers.com/jobs/ext/2000968-lead-software-engineer-data-engineering) at **Dynatrace** - [Senior Backend Engineer (Java)](https://www.wearedevelopers.com/jobs/ext/19369-senior-backend-engineer-java) at **Bonial International GmbH**