---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://mixpeek.com/.well-known/search?q={query}"
  method: GET
  documentation: "https://mixpeek.com/llms.txt"
---

Search & Discovery

8 min read

Updated 2026-07-15

# How Do I Filter Vector Search Results by Location? (Radius, Bounding Box, Polygon)

Filter vector-search and retriever results by geographic location with three operators in an attribute\_filter stage: geo\_radius (within N meters), geo\_bounding\_box, and geo\_polygon. Exact request shapes, the lat/lon-vs-GeoJSON lon-first gotcha, when to use each operator, combining geo with semantic search and metadata for location-aware RAG, and honest scope (a precise scan over your retrieved set, not a planet-scale geo index).

![Ethan Steininger](/people/ethan.webp)

By [Ethan Steininger](/blog/authors/ethan), Founder & CEO, Mixpeek

Geospatial Search

Vector Search

Filters

Location-Aware RAG

Proximity Search

[Run this on your own data. Try it as you read.Search your own archive →](https://studio.mixpeek.com/namespaces/create?mode=managed&utm_source=homepage&utm_medium=guide_cta&utm_campaign=mvs_onramp)

[One-click templatesStart from a templateEach template deploys a working search app on your own files.Browse templates](/templates)

## The Short Answer

  
  
To filter vector-search or retriever results by geographic location, add an `attribute_filter` stage with one of three geospatial operators over a `location` field: **geo\_radius** (within N meters of a point), **geo\_bounding\_box** (inside a lat/lon box), or **geo\_polygon** (inside an arbitrary shape). Radius is always in **meters**. Because it is a real filter stage, geo composes with the rest of a retriever: you can run a semantic vector query, keep only the results within 5km of a location, and apply a metadata filter, all in one request. A document with no location field is simply a non-match; malformed geometry is rejected at request time.  
  

## The three operators

  
  
Each is a condition inside an `attribute_filter` stage. The field (`location` here) holds a geographic point.

// geo\_radius — within 5,000 meters (5 km) of a center point (haversine)
{ "field": "location", "operator": "geo\_radius",
  "value": { "center": { "lat": 48.8584, "lon": 2.2945 }, "radius": 5000 } }

// geo\_bounding\_box — top\_left (NW) and bottom\_right (SE) corners
{ "field": "location", "operator": "geo\_bounding\_box",
  "value": { "top\_left":     { "lat": 49.0, "lon": 2.0 },
             "bottom\_right": { "lat": 48.0, "lon": 3.0 } } }

// geo\_polygon — an exterior ring of >= 3 points (auto-closed)
{ "field": "location", "operator": "geo\_polygon",
  "value": { "exterior": { "points": \[
    { "lat": 48.0, "lon": 2.0 }, { "lat": 49.0, "lon": 2.0 },
    { "lat": 49.0, "lon": 3.0 }, { "lat": 48.0, "lon": 3.0 } \] } } }

The one number to remember: **radius is in meters**, not kilometers or miles, 5km is `5000`. Distances use the haversine formula on a spherical earth, which is accurate to a fraction of a percent at city and metro scale.  
  

## lat/lon objects vs GeoJSON arrays: the one gotcha

  
  
A point can be written two ways, and one of them trips people up:  
  

Form

Example

Order

Object (recommended)

`{ "lat": 40.7128, "lon": -74.0060 }`

named, unambiguous

GeoJSON array

`[-74.0060, 40.7128]`

**lon first**, then lat

  
  
Lead with the object form: it names each value, so nobody has to remember an order. The array form follows the GeoJSON convention of **longitude first**: the reverse of how people say "lat, long" out loud, which is the single most common geo bug. If you store points as arrays, store them lon-first; if you are not sure, use the object form. A field can also hold a \*list\* of points (for example, every store in a chain), in which case the document matches if any of its points satisfies the operator.  
  

## Which operator should I use: radius, bounding box, or polygon?

  
  

Operator

Use when…

Shape it expresses

`geo_radius`

"within X of here": proximity, delivery range, "near me"

A circle around a point

`geo_bounding_box`

a rectangular region, map viewport, or quick metro-area cut

An axis-aligned rectangle (antimeridian-safe)

`geo_polygon`

real boundaries: a neighborhood, delivery zone, sales territory, school district

Any closed shape you can trace

  
  
Rule of thumb: reach for **radius** for anything distance-based ("stores within 10km"), **bounding box** when a rectangle is good enough and you want the simplest possible region (a map's current view), and **polygon** only when the boundary is genuinely irregular and a circle or box would include or exclude the wrong places. A polygon of a delivery zone is worth the extra points; a polygon approximating a circle is not: use radius.  
  

## Combining geo with semantic search and metadata (location-aware RAG)

  
  
The reason geo lives in a retriever stage rather than a separate endpoint is composition. A single retriever can: run a semantic/vector query over your content, filter to a radius, and apply a metadata constraint, so "find listings that \*look like\* this photo, within 3km of downtown, under $2,000/month" is one request, not three round-trips and a manual intersection. This is the [filtered vector search](/guides/filtered-vector-search-pre-post-in-place) pattern with a geographic predicate, and it is what makes location-aware [RAG](/guides/deep-research-agent-over-your-own-data) and recommendations possible: the language model only ever sees candidates that are both semantically relevant and in the right place.  
  

## How fast is it, and where does it fit?

  
  
Be honest with yourself about scope: geospatial filtering runs as a **scan over the candidate set your retriever produces**, not a planet-scale geo index. In practice that is exactly what you want for the common case: you are refining a retrieved or metadata-narrowed set down to the ones in the right place, precisely. The pattern that stays fast: pair geo with a **selective metadata filter or a vector query first**, so geo evaluates over a focused candidate set rather than an entire large collection. Think "precise geo filtering on your retrieved results," not "the primary index for a billion global points." (Perf characteristics are being measured; this guide states behavior, not benchmark numbers.)  
  

## What can you build with it?

  
  
*   **Store locator / proximity search**: `geo_radius` around the user's location to find the nearest branches, ranked by the semantic or attribute signal you already search on.
*   **Delivery-radius filtering**: only show inventory from fulfillment points that can actually reach the customer.
*   **Geo-fenced content**: restrict results to a licensing region, a market, or a campaign area with `geo_bounding_box` or `geo_polygon`.
*   **Real-estate and POI search**: "apartments like this one, inside this neighborhood polygon" combines visual/text similarity with a real boundary.
*   **Location-aware recommendations**: bias or hard-filter recommendations to what is reachable, so "similar restaurants" never surfaces one three cities away.
  
  

## Doing it in Mixpeek

  
  
Two steps. First, put a `location` field on your documents: a `{ "lat", "lon" }` object (or a lon-first GeoJSON array) in the payload, alongside whatever else you index. Then add the operator to a retriever's `attribute_filter` stage next to your `feature_search` and metadata filters; the [filter operators reference](/docs/retrieval/filters) has the exact request shapes and a worked example, and the [retriever stage catalog](/docs/retrieval/stages/overview) shows where the filter sits in a multi-stage pipeline. Geo works the same whether you run [managed indexing](/pricing) or bring your own vectors to [MVS](/mvs): it is a filter over stored payloads, so any namespace with a location field can use it. For the broader picture of how filters interact with the vector search stage, see [filtered vector search: pre-, post-, and in-place](/guides/filtered-vector-search-pre-post-in-place).

## Run this on your own data

Point Mixpeek at the storage you already have and search your video, images, audio, and documents the way this guide describes. Build starts at $25/mo for up to 1M vectors.

[Search your own archive](https://studio.mixpeek.com/namespaces/create?mode=managed&utm_source=homepage&utm_medium=guide_cta&utm_campaign=mvs_onramp)[Read Docs](/docs)

[Explore MVS](/mvs)[See pricing](/pricing)

## Related guides

[

Search & Discovery

### Why Does My Vector Search Return Fewer Results When I Add a Filter?

Most vector indexes find candidates first and filter afterwards, so a narrow filter leaves fewer results than you asked for, or a full page that misses the true nearest matches. How to check filtered recall on your own data, what to change in pgvector, Qdrant and Weaviate, and our own before and after numbers on 1 million vectors.

Read guide →](/guides/why-vector-search-returns-fewer-results-with-filter)[

Search & Discovery

### Why Can't My Search Find Exact Part Numbers, Codes or Names?

Semantic search compares meanings, and a part number, an error code or an unusual surname carries almost none, so the index returns records that look alike instead of the one that matches. Run a keyword (BM25) search beside the vector search, merge the two lists by rank, and use an exact filter when the identifier lives in its own field.

Read guide →](/guides/why-search-cant-find-exact-part-numbers-codes-names)[

Search & Discovery

### Why Do My Search Results Get Worse as I Add More Data?

Search that worked on ten thousand items and fails on ten million usually has one of five causes: a candidate budget that is a count rather than a fraction, near-duplicates filling the top ten, a coarse index trained on data that no longer looks like yours, a score floor calibrated on a smaller corpus, or a filter starving the candidate pool. This explains each mechanism, the single test that identifies it, and the order to run the tests in.

Read guide →](/guides/why-search-results-get-worse-as-you-add-more-data)