Skip to main content
Prerequisites
TopK enables you to search the text and images in your documents by meaning with just a few lines of code. There is no embedding pipeline to build, no vector store to operate, and no reranking service to maintain. It’s as simple as adding semantic_index() to a field in your collection schema and querying with fn.semantic_similarity():
Under the hood, semantic_index() is powered by the production model of topk-embed-v1, TopK’s own family of multi-vector embedding models, combined with Sparse Multi-Vector Encoding (SMVE) for scalable retrieval and quantized MaxSim reranking. Learn more about the smaller models in the family, topk-embed-v1-xsmall and topk-embed-v1-small.
Why multi-vector? Single-vector (dense) embeddings compress an entire document into one point in high-dimensional space.Multi-vector models like topk-embed-v1 keep one embedding per token, enabling token-level matching via MaxSim scoring. This consistently outperforms dense models on out-of-domain content, long documents, specific clauses, tables, and structured data.Read Introducing topk-embed-v1 for model benchmarks and High-Quality Search, Out of the Box for a deep-dive into the architecture.
In the following example, we’ll:
1

Define a collection schema

Create a collection configured for semantic search.
2

Add documents

Insert documents into the collection.
3

Run a semantic query

Search the title text field by meaning with a free-form query.

Define a collection schema

Semantic search is enabled by adding a semantic_index() to a text() field in the collection schema:
This configuration automatically generates multi-vector embeddings for the field and enables keyword search. Documents are indexed within a second — they are searchable as soon as they are written.
If you want to use your own embeddings instead of TopK’s built-in semantic_index(), see Vector Search guide.

Add documents to the collection

Let’s add some documents to the collection:

Run a semantic query

To search for documents based on semantic similarity, use the fn.semantic_similarity() function:
Let’s break down the example above:
1

Encode and score

The semantic_similarity() function encodes the query "classic American novel" into multi-vector token embeddings using the topk-embed-v1 production model and scores each document via quantized MaxSim — comparing every query token against every document token to find the best alignment.
2

Retrieve candidates

Candidate retrieval is accelerated by SMVE, which uses fast sparse approximations to identify a small set of candidates before the full MaxSim pass.
3

Rank results

The results are ranked by their MaxSim score and the top 10 most relevant documents are returned.
This works out of the box—no embedding pipeline, no vector store, no reranking service to manage.

Searching images

semantic_index() also works on image() fields, so you can search images with a free-form text query. TopK embeds the images for you with the same model it uses for text: topk-embed-v1 is multimodal.

Define an image field

Add a semantic_index() to an image() field:

Add images

Images are stored as JPEG or PNG, up to 512KB each (see limits).

Query images with text

Pass the image field to fn.semantic_similarity() together with a text query:
Stored raw images can’t be selected in queries. To fetch the raw document, use the Get API with the _ids returned by the query:

Inference

Model version

Adding a semantic_index() does not specify a model or a model version. For embedding, the latest generation of topk-embed models (topk-embed-v1) is used.
Text and image fields are embedded by the same model.
For certain use cases, you might want to use a combination of keyword search and semantic search:
This example above combines keyword relevance (BM25) with semantic similarity,
ensuring your search results capture both exact matches and contextual meaning with a custom scoring function that’s best suited for your use case.