How it works
When you run Search, TopK:Searches across your documents
TopK searches one or more datasets for the passages most relevant to the query.
Example search results
- RAG pipelines
- building custom answering or summarization layers on top of retrieved passages
- feeding high-signal evidence into agents or downstream workflows
- inspecting and verifying source passages directly
- semantic search in applications
Usage
Once your documents are processed, you can start retrieving relevant passages immediately.- CLI
Python SDK
JavaScript SDK
Scoping the search
Query across multiple datasets or apply document filters to narrow the scope of the query.Scoping to specific datasets
This is useful when you want:- More targeted results
- Less ambiguity across unrelated document sets
- Tighter control over what content an agent is allowed to see
- CLI
Python SDK
JavaScript SDK
Use
-d / --dataset (repeatable):Filter documents
Sometimes a dataset might contain documents that should not be considered for the query. You can filter out documents that don’t match your criteria by providing a filter expression. These filter expressions operate on the metadata fields of documents. For example, if you uploaded documents with metadata such asdepartment, year, doc_type, or author, you can use those fields to limit what Ask is allowed to retrieve.
This is useful when you want to query:
- Documents within a specific time range
- Documents matching a particular category or type
- Documents associated with a specific group or owner
- Documents the user is permitted to access
Python SDK
JavaScript SDK
Retrieving metadata
The passage text alone is often not enough. You may also want metadata such as title, author, date, or any custom fields you attached during upload — to render richer results, group by source attributes, or carry context into downstream agents.- CLI
Python SDK
JavaScript SDK
Use
--field (repeatable):