Jump to the manifest
document-intelligence.namespace.yaml: apply it with one API call, then read the walkthrough below to change it.At a glance
How the pieces connect
Buckets hold what you upload, collections turn it into searchable documents, and retrievers answer queries over the collections.Deploy it
1
Get the manifest
2
Validate it
Validate runs every check apply runs and creates nothing. Fix each entry in
errors, then run it again.3
Apply it
Apply creates every resource in one call. The response lists each resource with its outcome in
wait_for_seed=true also waits until the sample objects are processed, so the first query below has documents to return.resources. Apply refuses a resource that already exists and rolls the whole apply back, so to apply the file again over this namespace add ?mode=create_missing, which creates only what is missing.Run the first query
Look up the namespace id by name, then rundocument-search. Check status and warnings along with documents: a run that times out still answers 200, with status degraded.
Add your own data
Each object you add to a bucket is processed by every collection that reads it. This adds one object todocuments. NAMESPACE_ID is the id from the namespace lookup above.
PENDING until processing finishes, then COMPLETED or FAILED. Buckets and objects covers object states, retries and duplicates.
Retrievers
document-search
Describe what you are looking for and get back the pages closest in meaning, from any file, best first.
Stages: feature_search
Searches: document-pages
document-search-by-file
The same search, with matching pages gathered under the file they came from: at most 3 pages per file, files ordered by their best page.
Stages: feature_search → group_by
Searches: document-pages
Collections
Each collection runs one extractor over a bucket, or over another collection’s documents.document-pages
document-pages
universal_extractor@v1 over bucket documents: one document per page, carrying the page’s text (its text layer, or OCR for a scan), a generated description and a Gemini Embedding 2 vector. Feeds document-search and document-search-by-file.Reads bucket
documents with universal_extractor v1.Inputs: content ← documentCopied onto each document: title, document_type, issuerThe manifest
Every resource above comes from this file. Change it and apply it again with?mode=upsert to update what exists. Manifests documents each field.
document-intelligence.namespace.yaml
Hand it to an agent
Paste this prompt into Claude Code, Cursor or another coding agent. To give the agent this whole page instead, use Copy page in the menu at the top of the page, or point it at the page’s Markdown athttps://mixpeek.com/docs/templates/document-intelligence.md.
Prompt
How it works
universal_extractor reads the bucket’s document property, detects that the file is a document, and works page by page. Each page becomes one document in document-pages with these fields:
Each page also gets a 3072-dimension vector from Gemini Embedding 2, which both retrievers search as
mixpeek://universal_extractor@v1/gemini-embedding-2. Gemini Embedding 2 puts text, images, audio, video and PDFs in one vector space, so a text query compares directly with a page.
The parameters in the manifest:
extract_text: truewritestext. Turn it off and pages are still searchable by their vector, but there is no text to read, filter on, rerank or match with BM25.generate_description: truewritesdescription.max_document_pages: 10caps the pages processed per file (default 50, ceiling 200). Raise it before you upload longer files.
?mode=upsert.
Find pages, then files
document-search returns pages. Two pages from the same file come back as two documents, each with its own score.
document-search-by-file adds a group_by stage on source_object_id, the bucket object each page came from:
max_per_group: 3keeps the 3 best pages of each file.output_mode: allreturns each group with its pages. Usefirstfor one page per file, the best match, orflattenfor a plain list with at most 3 pages per file.
final_top_k: 50 on the search gives the grouping enough pages to fill several files.
To trace any page back to its file and the collections that processed it, read its lineage. Each document carries collection_id and document_id:
cURL
Filter by document type
Every page carries its file’sdocument_type and issuer, both indexed as keyword. Send filters in the execute body to search one kind of file:
cURL
pre_filters on the search stage, beside parameters:
document-search stages, IRS forms only
Match form numbers and exact terms
An embedding treats a form number like “1040” as a loose number. Add a BM25 search over the extracted page text, which the namespace already indexes astext, and fuse it with the dense search:
document-search stages, dense plus BM25
lexical: true searches no vector: it matches the query’s words against the text index, and its feature_uri only scopes it to this collection. rrf merges the two lists by rank.
Rerank pages
A cross-encoder orders pages more precisely than vector distance. Add arerank stage after the search and point it at text:
document-search stages, with a rerank stage
document_field is content, which these pages do not have, and a document without the field is left out. max_candidates caps how many pages are scored; at 4 CPU, 10 documents take about 8 seconds with BAAI__bge_reranker_v2_m3.
Change what is extracted
Editfeature_extractor.parameters on document-pages:
document-pages feature_extractor.parameters
generate_description: falseskips the Gemini call that writesdescription.output_dimensionality(256 to 3072) shrinks the vectors. It resizes the vector index, so set it before the first upload: a collection that already holds documents refuses a change to it.
The collection reads one property per object. To also index phone photos of documents, add a bucket with an
image property and a second collection with universal_extractor over it. Both collections share the Gemini Embedding 2 space, so list both in the retriever’s collections and one query searches PDFs and photos together.Next steps
Universal extractor
Every parameter and output field, for documents, images, audio and video.
Group By
Grouping modes, ordering within a group and caps on group position.
Classify documents
Label each file by type (contract, invoice, form) with a taxonomy.
Text extractor
Run a second collection over the page text for chunking and structured extraction.

