Field mapping is where null-value problems in document filters usually begin.
Before a search engine or vector database can filter documents, an ingestion pipeline has to map source fields into filterable metadata. That mapping decides whether a missing source value becomes null, an empty string, an empty array, a default value, a status flag, or no field at all.
If those choices are inconsistent, filters become unpredictable. A RAG system may miss relevant documents, include documents from the wrong category, or hide data-quality problems that should have been visible during ingestion.
Short Answer
Field mappings should treat null values explicitly. Do not pass source data directly into document filters without deciding what missing, blank, empty, unknown, not-applicable, and redacted values mean.
For each filterable field, define four things: the source field, the normalized target field, the allowed absence states, and the filter behavior for each state.
What Field Mapping Means
Field mapping is the process of converting source data into the schema used by a search or retrieval system.
For example, a document source may contain fields such as:
{
"dept": "Legal",
"geo": "EMEA",
"tags": null,
"published": "yes"
}
The search system may need cleaner fields:
{
"department": "legal",
"region": "emea",
"tags": [],
"tags_status": "not_provided",
"is_published": true
}
The mapping step is where raw source variation becomes stable filter behavior.
Why Null Values Make Mapping Hard
Null values are difficult because they can mean different things in different source systems.
A null region might mean the region is unknown. A null renewal_date might mean the document is not a contract. A null access_group might mean the permissions job failed.
Those cases should not be mapped the same way.
Separate Source Absence From Filter Semantics
A good mapping does not only copy values. It translates source absence into application meaning.
For each field, ask:
- Was the source field missing?
- Was the source field present but null?
- Was the source field blank?
- Does the field apply to this document type?
- Should this absence be searchable?
- Should this absence block retrieval?
The answers determine how the target metadata should be stored.
Common Mapping Choices
There are several ways to map null-like source data.
- Keep null: useful when the database can index and filter null state.
- Omit the field: useful when missing values should not appear in filter indexes.
- Use a default value: useful when a safe, truthful default exists.
- Use an empty string: rarely ideal for filter fields unless blank text has meaning.
- Use an empty array: useful when a list is known to have zero items.
- Use a status field: best when the reason for absence matters.
The mistake is choosing these casually. Each choice changes how filters behave later.
Use Defaults Carefully
Defaults can simplify filters, but they can also hide bad data.
For example, defaulting a missing language field to en may improve coverage if most documents are English. But it can also cause non-English documents to appear in English-only retrieval.
Defaults are safest when they are business rules, not guesses.
Use Status Fields for Important Absence
When absence has meaning, map it into a status field.
{
"review_date": null,
"review_date_status": "not_applicable"
}
This is more useful than storing only:
{
"review_date": null
}
With a status field, filters can distinguish documents that need cleanup from documents where the field does not apply.
Mapping Arrays and Tags
Array fields need special care because null and empty arrays are not always the same.
A null tags field may mean tags were not extracted. An empty tags array may mean extraction ran and found no tags.
A reliable mapping might store:
{
"tags": [],
"tags_status": "extracted_empty",
"tag_count": 0
}
This gives the filter layer clear options: find untagged documents, find documents where tagging failed, or search by tag count.
Mapping Access-Control Fields
Access-control metadata should be mapped more strictly than ordinary descriptive metadata.
If tenant_id, visibility, or allowed_roles is missing, the safe default is usually to exclude the document from retrieval until the metadata is fixed.
Do not map missing permission fields to broad access values such as public or all unless that rule is explicitly guaranteed by the source system.
Mapping Text Fields for Vector Search
Field mapping also affects embeddings.
Some fields should be used for filters but not for vectorization. Internal IDs, timestamps, status flags, tenant IDs, and access-control values usually add noise to semantic meaning.
A clean design separates fields used for vector search from fields used for filtering.
Example Mapping Policy
A simple mapping policy might look like this:
title: required text; reject document if missing.body: required text; reject or quarantine if blank.region: optional filter field; map missing to null andregion_status = unknown.tags: array field; map missing to[]only if extraction ran successfully.tenant_id: required access field; quarantine document if missing.published_at: optional date; use null plus status if unknown.
This policy is simple, but it prevents each ingestion job from inventing its own null behavior.
Filter Behavior Should Be Tested
After mapping fields, test filter behavior with representative records.
Include examples where fields are known, null, missing, blank, empty, unknown, not applicable, and invalid.
For each important filter, confirm which records should match and which should not.
Common Mistakes
- Letting each connector map null values differently.
- Using empty strings as a substitute for every missing text field.
- Using empty arrays when extraction did not actually run.
- Defaulting missing access metadata to permissive values.
- Vectorizing metadata fields that should only be filterable.
- Forgetting to index null state or property length when filters depend on them.
- Failing to store data-quality status fields.
Implementation Example With Weaviate
In Weaviate, teams should define an explicit schema for production and consider which fields are filterable, vectorized, nullable, or length-filtered.
from weaviate.classes.config import Configure, Property, DataType
from weaviate.classes.query import Filter
# Example configuration idea for a document collection.
inverted_index_config = Configure.inverted_index(
index_null_state=True,
index_property_length=True
)
properties = [
Property(name="title", data_type=DataType.TEXT),
Property(name="body", data_type=DataType.TEXT),
Property(name="region", data_type=DataType.TEXT),
Property(name="region_status", data_type=DataType.TEXT),
Property(name="tags", data_type=DataType.TEXT_ARRAY),
Property(name="tenant_id", data_type=DataType.TEXT),
]
# Example filters after mapping.
missing_region = Filter.by_property("region").is_none(True)
known_region = Filter.by_property("region_status").equal("known")
empty_tags = Filter.by_property("tags", length=True).equal(0)
The key is to configure the index for the states you intend to query and to map source values consistently before inserting documents.
Best Practices
- Write a field-mapping contract before ingestion.
- Separate raw source fields from normalized filter fields.
- Use status fields when absence has operational meaning.
- Normalize casing and naming for categorical filters.
- Keep access-control fields required and explicit.
- Do not vectorize metadata unless it improves semantic meaning.
- Run filter tests on edge-case documents before production rollout.
Summary
Field mapping determines how null values behave in document filters.
A reliable mapping turns messy source data into clear filterable metadata. It decides when to keep nulls, when to use defaults, when to store empty arrays, when to omit fields, and when to add status fields.
For RAG and search systems, good field mapping makes retrieval more predictable, access control safer, and data-quality problems easier to diagnose.