How Does Document Filtering Using Field Mappings Work?
Document filtering using field mappings works by declaring which fields in your documents (metadata like category, date, status, price, or ID) are mapped to structured, indexed properties at the time your data is stored, so that a search system can build a fast lookup — typically an inverted index — over those fields and use it to narrow down candidate documents before or after a similarity search runs. In short: you map raw document fields to typed, indexed properties up front, and that mapping is what lets a query later say “only consider documents where category equals X and date is after Y” without scanning every document by hand.

What a Field Mapping Actually Is
When you store a document in a search or vector system, it usually isn’t just one blob of text. A support ticket has a body, but also a status, a priority, a creation date, and a customer ID. A product listing has a description, but also a price, a category, and a stock flag. A “field mapping” is the decision, made when you define your schema, about which of these pieces of a document become separate, structured properties that the system indexes individually — as opposed to fields that just get folded into a single block of unstructured text.
This distinction matters because it determines what kind of query you can later run against each field. A field that’s mapped and indexed as, say, a date or a boolean can be used in precise structured filters — “before this timestamp,” “equals true,” “greater than this number.” A field that’s left unmapped, or buried inside free text, can only be searched the way you search any other text: by relevance, not by exact structured comparison.
Why an Inverted Index Is the Mechanism Behind This
The reason field mappings enable fast filtering is the data structure underneath them: an inverted index, the same fundamental idea that traditional keyword search engines have used for decades. Instead of scanning every document to check whether it matches a condition, the system pre-builds, at ingestion time, a reverse lookup from field values to the document IDs that hold them. If a hundred documents have `category = “electronics”`, the inverted index already knows exactly which hundred document IDs those are, so a filter query on that field is a fast lookup rather than a full scan.

This is what makes field mapping a deliberate design decision rather than an afterthought: a field that was never indexed this way has no such lookup structure built for it, so filtering on it later — if it’s even possible — falls back to something much slower.
Combining Field-Based Filters With Similarity Search
In systems that also do semantic or vector-based search, field-mapped filtering doesn’t replace similarity search — it constrains it. The two most common ways of combining them behave very differently:
- Post-filtering: run the similarity search first across the whole collection, get back the top matches, then throw away any that fail the field-based filter afterward. This is simple to implement but fragile: if the filter is restrictive, you can end up with far fewer usable results than you asked for, or even zero, because the initial similarity search had no idea the filter existed.
- Pre-filtering: evaluate the field-mapped filter first, using the inverted index to build an “allow-list” of document IDs that satisfy it, and only then run the similarity search — constrained to consider just that allow-list. This guarantees your results actually satisfy the filter, since anything that fails it was never eligible to be returned in the first place.
Pre-filtering is generally the more robust approach precisely because it treats the field mapping as a first-class part of the query plan rather than a cleanup step tacked on at the end.
Deciding Which Fields to Map
Not every field in a document deserves to become an indexed, filterable property, and treating every field as if it does adds indexing overhead without adding useful capability. A few practical guidelines help:

- Map fields that show up in real filter conditions. Status flags, categories, dates, prices, tenant or customer identifiers — anything you expect users or your application logic to filter, sort, or range-query on — should be explicit, typed, indexed properties.
- Don’t force free-form text fields into rigid field mappings just to filter on them loosely. If what you actually want is “documents somewhat related to X,” that’s a job for similarity or full-text search, not a structured field filter.
- Be deliberate about metadata that isn’t indexed by default. Many systems don’t automatically index things like creation timestamps, null states, or property lengths — these need to be explicitly turned on in the schema if you intend to filter on them, otherwise a filter that references them will either fail or silently fall back to something much slower.
- Keep noisy or purely internal fields out of anything that also feeds semantic search. Internal IDs, raw timestamps, and status codes rarely carry meaningful semantic content, and letting them leak into the text used for similarity search just adds noise to the embedding without adding filtering value — they belong in the structured, filterable side of the schema instead.
Nested and Structured Metadata
Real-world documents often carry metadata that isn’t flat — a document might have an array of associated objects, each with their own sub-fields, like a product with multiple variants, or a car with a list of parts, each of which has its own attributes. Modern field-mapping schemes increasingly support filtering into this kind of nested structure directly, using a path-like syntax to reach a specific nested field — either matching if any element in an array satisfies a condition, or pinning to one specific element by position. This lets a single document carry rich, structured, and filterable metadata without having to flatten everything into the top level of the schema or split it into many separate documents just to make it filterable.
Example: Field Mappings in a Vector Database Schema
Concretely, defining a field mapping usually looks like declaring a typed property alongside your text content when you create a collection or index, and then referencing that property name in your filter conditions at query time. Here’s what that looks like using Weaviate as the underlying vector database:
from weaviate.classes.config import Configure, Property, DataType, Tokenization
from weaviate.classes.query import Filter
# Mapping document fields to structured, filterable properties
client.collections.create(
name="SupportTickets",
properties=[
Property(name="body", data_type=DataType.TEXT),
Property(name="status", data_type=DataType.TEXT, tokenization=Tokenization.FIELD),
Property(name="priority", data_type=DataType.TEXT, tokenization=Tokenization.FIELD),
Property(name="customer_id", data_type=DataType.TEXT, skip_vectorization=True),
],
vector_config=Configure.Vectors.text2vec_weaviate(
source_properties=["body"] # only free text feeds the semantic vector
),
inverted_index_config=Configure.inverted_index(
index_timestamps=True
),
)
tickets = client.collections.use("SupportTickets")
# Filtering using the mapped fields, combined with semantic search on the body
response = tickets.query.near_text(
query="customer can't reset their password",
filters=(
Filter.by_property("status").equal("open") &
Filter.by_property("priority").equal("high")
),
limit=5,
)
Notice that only `body` is passed into the vectorizer’s source properties — that’s the field mapping decision that keeps the semantic vector clean, while `status`, `priority`, and `customer_id` are mapped as separate, indexed properties purely for structured filtering. The filter conditions in the query then reference those mapped field names directly, and because they were declared and indexed up front, the database can resolve them to an allow-list before it ever has to compare a single vector.
The Underlying Principle
Whatever the specific database or search system, the pattern is the same: filtering is only as good as the schema decisions made before any query is ever written. A field that was never mapped to an indexed property can’t be filtered on efficiently later, no matter how clever the query engine is. Getting field mappings right — deciding deliberately which pieces of a document are structured, filterable metadata versus which are free text meant for semantic matching — is what turns “search everything and hope” into “ask exactly the question you meant to ask.”