Skip to main content
Filter composition: AND, OR, and NOT operators nest to build complex filter logic on document payloads
Filters narrow results using logical operators to combine conditions. They operate on document payloads (metadata, enrichments, passthrough fields) and can be applied in retriever execution or as dedicated filter@v1 stages.

Payload Indexes

Filters require payload indexes on the fields you filter by. Without an index, the vector store performs a full scan — which is slow on large collections and may return incomplete results.
Create indexes on your namespace before using filters:
Supported index types: If you filter on an unindexed field, the response includes a warnings array telling you which fields need indexes:
System fields (collection_id, bucket_id, object_id, batch_id) and _internal.* fields are indexed automatically — you only need to create indexes for your own fields.

Logical Operators

Mixpeek filters support three logical operators for composing conditions:

AND Operator

Requires all nested conditions to match:

OR Operator

Matches if any nested condition is true:

NOT Operator

Excludes documents matching the condition:

Nesting Operators

Logical operators can be nested to create complex filter logic:
This filter matches documents that are:
  • Published AND
  • Either video or audio AND
  • Not restricted

Comparison Operators

Use these operators within conditions:
Use text to match any of the query tokens (BM25); use phrase when word order matters — e.g. find a transcript where someone says an exact quote. { "field": "transcription", "operator": "phrase", "value": "make america great again" } matches “…make america great again…” but not “america will be great again”.

Geospatial Operators

Three operators filter by geographic location. Their value is an object, not a scalar. See Geospatial filtering for field formats, exact shapes, worked examples, and the [lon, lat] GeoJSON caveat.

Geospatial Operators

Geospatial operators filter documents by a location field — a payload value holding a geographic point. A point may be either an object { "lat": <num>, "lon": <num> } or a GeoJSON-style [lon, lat] array. A field holding a list of points matches if any point satisfies the predicate. Each operator takes a structured value:
Distances use the haversine formula on a spherical earth (R = 6,371,000 m). Bounding boxes handle the antimeridian: when top_left.lon > bottom_right.lon the box is treated as wrapping across ±180°. Malformed geometry (out-of-range lat/lon, a missing corner, or fewer than 3 polygon points) is rejected at request time with a descriptive error; a document whose location field is missing or unparseable is a non-match (it is never an error).

Lineage Shortcuts

Every Mixpeek document carries a _internal.lineage block recording where it came from. To filter by lineage you don’t have to use the underscore-prefixed paths — use the friendly aliases below in any field position.
You can mix lineage aliases with regular fields and templates:
The aliases are also accepted by document list endpoints and retriever filter stages — the same vocabulary works everywhere field is used.

Using Templates

Reference request inputs or stage outputs in filter values:

Filter Stage Example

Stage Pre-Filters and Post-Filters

Every stage in a retriever pipeline accepts optional pre_filters and post_filters. pre_filters narrow the candidate set before the stage runs (pushed down into the vector store as native filters); post_filters apply to the stage’s results before they pass downstream. Both take the same logical-operator shape as any other filter. Canonical shape — wrap conditions in an explicit logical operator:
Always prefer the explicit { "AND": [ ... ] } form — it is unambiguous and nests cleanly with OR/NOT.
For convenience, two shorthand forms are coerced to an AND group:
  • a single bare condition{ "field": "...", "operator": "...", "value": "..." } becomes { "AND": [ <condition> ] }
  • a list of conditions[ { ... }, { ... } ] becomes { "AND": [ ... ] }
Each condition must carry all three of field, operator, and value. An incomplete condition (for example, a missing operator) is rejected with a clear error rather than silently ignored — so a typo can never quietly degrade into an unfiltered result.

Options