Skip to main content
Attribute Filter stage showing metadata-based document filtering
The Attribute Filter stage filters documents based on metadata field conditions. It supports simple single-field filtering and complex boolean logic (AND/OR/NOT). When used as a first stage, it retrieves documents directly from the database; when used after other stages, it filters in-memory results.
Stage Category: FILTER (Reduces document set)Transformation: N documents → M documents (where M ≤ N, based on conditions)

When to Use

When NOT to Use

Parameters

Simple Mode

Use for single-condition filtering:

Boolean Mode

Use for complex multi-condition filtering:

Natural-Language Mode

Supply a plain-English filter and let an LLM compile it to a structured conditions tree at runtime. Useful when the filter shape is derived from user input or when field names are unknown in advance.
NL mode rides the wave — better LLMs produce better filter trees. Takes precedence over simple-mode fields; ignored if conditions is also set. Adds one LLM call per execution (~200-500ms).

Supported Operators

The three geo_* operators take an object as their value, not a scalar. See Geospatial filtering for the field format and exact value shapes.

Configuration Examples

Boolean Conditions

For complex filtering, use the conditions parameter with AND/OR/NOT logic:

Geospatial filtering

Filter documents by geographic location. Three operators — geo_radius, geo_bounding_box, and geo_polygon — restrict results to documents whose location falls within a circle, a box, or an arbitrary polygon. They work in both simple mode and inside boolean conditions, exactly like any other operator.

The location field

A document is geo-filterable when it carries a location field. By convention the field is named location, and Mixpeek resolves it wherever it lives — it tries top-level location, then metadata.location, then _internal.metadata.location — so you write "field": "location" regardless of how the document was ingested. A location value can be either of two forms:
GeoJSON arrays are [lon, lat], not [lat, lon]. This is the single most common geo footgun. [-73.9855, 40.758] is Manhattan; [40.758, -73.9855] is an invalid point (latitude 40.758 is fine, but longitude 40.758 places it in the Indian Ocean, and if either value exceeds its range the point is dropped). Prefer the {"lat": ..., "lon": ...} object form, which is unambiguous.
A document with no location field never matches a geo filter (it is treated as a non-match, not an error). If a document stores a list of points, it matches when any point satisfies the filter.

The three operators

radius is always in meters15000 is 15 km, not 15,000 km.
Geo operators are evaluated by a payload scan — they are correct but not index-accelerated (there is no geo postings index yet). To keep the candidate set small and latency low, pair a geo condition with a selective non-geo condition (a brand, category, or status equality) inside an AND:
The selective eq narrows the set first; the geo condition is then applied to a small candidate list. Don’t rely on a geo-only filter over a large collection for sub-millisecond latency.

Validation

Malformed geo specs fail loudly at request time with a message that names the expected shape — you get a clear 400, not a silent empty result set. Common mistakes that are rejected:
  • value is not an object (e.g. a bare number or string)
  • center / top_left / bottom_right missing lat or lon, or out of range
  • radius missing or negative
  • geo_polygon with fewer than 3 points, or a point missing lat/lon

Worked example

Six documents, each an office with a location (one has none): Applying each operator from the examples above: In every case the Virtual office (no location) is excluded.

First-Stage vs Later-Stage Behavior

First-Stage Example

When no documents exist in the pipeline yet:

Later-Stage Example

After semantic search:

Performance

For best performance with feature_search, use pre-filters in the search stage instead of a separate attribute_filter stage. Pre-filters are applied at the vector index level.

Common Pipeline Patterns

Search + Filter + Sort

Attribute-Only Retrieval (No Embeddings)

Multi-Stage Filtering

Comparison: attribute_filter vs feature_search Pre-Filters

Recommendation: When filtering during semantic search, prefer pre-filters in feature_search. Use attribute_filter for:
  • Post-search refinement based on previous stage outputs
  • First-stage attribute-only retrieval
  • Dynamic filters that depend on earlier stage results

Error Handling