Metadata filtering lets you attach structured key-value pairs to your files at index time, then narrow search results at query time using those fields. This is useful for scoping searches by department, date range, access level, content type, or any other dimension relevant to your data.
Pass custom_metadata on any indexing endpoint. Every chunk from that file inherits the metadata.
Metadata applies to all files in the indexing job.
Pass metadata_filter in the query request body to restrict results to chunks matching your criteria.
Filters work with both inference: true (AI-powered answers) and inference: false (raw search results).
Multiple fields at the top level are combined with AND:
This matches chunks where department is “finance” AND year is at least 2024 AND is_public is false.
Use $or to match chunks that satisfy any of the conditions:
Combine top-level AND with nested OR:
This matches chunks from 2024 or later in either the legal or finance department.
Index documents with metadata, then query with filters: