To run queries in TopK, your documents need to be uploaded. Once a document is uploaded,
TopK parses, chunks, and indexes its content to power Ask, Search, and Research.
# Upload all supported files in the directorytopk upload ./docs --dataset my-docs# Upload all supported files in the directory and subdirectories recursivelytopk upload ./docs -r --dataset my-docs# Upload all supported files in the directory by glob patterntopk upload "./docs/*" --dataset my-docs# Upload all supported files in the directory by glob pattern recursivelytopk upload "./docs/**/*" -r --dataset my-docs# Upload all PDFs in the directory by glob patterntopk upload "./docs/*.pdf" --dataset my-docs# Upload all PDFs in the directory by glob pattern recursivelytopk upload "./docs/**/*.pdf" --dataset my-docs# Upload a single file with an explicit document IDtopk upload ./report.pdf --dataset my-docs --id report-2024
Each document can be associated with metadata. This is useful for
storing additional information about the document, such as title, author, date,
category, or any custom metadata fields you want to attach to the document.Metadata values can also include arrays, for example tags or categories.
After a document is uploaded, TopK returns a processing handle — a reference to the processing job.
The document is not ready for retrieval until it has been processed.Processing happens asynchronously in the background and may take a few seconds to a few minutes, depending on document size and complexity.
Your documents might not be ready for retrieval immediately after upload.
Alternatively, you can wait for the document to be processed using the processing handle:
CLI
Python SDK
JavaScript SDK
Pass --wait to block until processing is complete:
topk upload ./report.pdf --dataset my-docs --wait
import osfrom topk_sdk import Clientclient = Client( api_key=os.environ["TOPK_API_KEY"], region=os.environ["TOPK_REGION"],)client.dataset("my-docs").wait_for_handle(resp.handle)# Document is now ready to be queried
import { Client } from "topk-js";const client = new Client({ apiKey: process.env.TOPK_API_KEY!, region: process.env.TOPK_REGION!,});await client.dataset("my-docs").waitForHandle(resp.handle);// Document is now ready to be queried