Advanced Search & Relations
Advanced Search & Relations
Advanced search in v3 File Search is built around three concepts:
- Document metadata: stable file-level fields used for query filters and source context.
- Chunk custom metadata: custom annotations attached to a specific chunk.
- Chunk relations: typed links between chunks for graph-aware retrieval and review workflows.
Start with the File Search API guide for the basic v3 query flow. This guide covers the knobs that make retrieval more precise.
Document Metadata Filters
Use filter on v3 Query to restrict retrieval to documents that match file-level metadata.
Document metadata is best for stable fields such as access tier, source system, review status, file owner, product line, year, or jurisdiction.
Supported operators include bare equality, $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $and, and $or.
Include Controls
Use include on v3 Query to request only the extra objects your application needs.
Keep regions, relations, and related_chunks off unless the caller needs them. The base query response is easier for agents to consume when it returns only source text and core metadata.
Chunk Custom Metadata
Use chunk metadata when your application needs annotations below the document level, such as claim type, reviewer status, extraction confidence, entity IDs, or a workflow state for one chunk.
The chunk metadata endpoints are:
Query and document responses expose these annotations as custom_metadata on chunks. The metadata endpoint request and response body uses metadata because the URL is already scoped to one chunk.
Documents, Chunks, and Regions
Use Get Document, List Chunks, and Get Chunk when you need source inspection without running a new search.
Set include_regions=true when the UI or downstream workflow needs extracted layout regions. Regions are useful for PDF and document review flows, but should not be requested by default in simple agent search flows.
Chunk Relations
Relations link one chunk to another with a typed edge. Use them when your application needs source graph behavior, such as cited-by links, contradiction links, section-to-table links, or claim-to-evidence links.
The relation endpoints are:
Relation-Aware Queries
Use include.relations, include.related_chunks, and relation_direction on v3 Query when a search result should carry graph context.
Use relation-aware queries when the graph should affect what the caller can inspect after retrieval. Use plain queries when the caller only needs the best matching source chunks.