TopK provides native support for sparse vector search, enabling exact retrieval over high-dimensional sparse representations. It is designed to:Documentation Index
Fetch the complete documentation index at: https://docs.topk.io/llms.txt
Use this file to discover all available pages before exploring further.
- Provide 100% recall (exact search).
- Support learned sparse representations such as SPLADE.
- Deliver consistent low latency (p99 < 20 ms). See the benchmarks for details.
- Support large-scale single-collection deployments as well as multi-tenant architectures.
Define a collection schema with a sparse vector field
Define a schema with a sparse vector field and add avector_index():
Sparse vectors do not have a fixed dimension, so you don’t need to specify the vector dimension when defining the field.
Perform a sparse vector search
To retrieve the top-k nearest neighbors of a query vector, use thefn.vector_distance() function.
fn.vector_distance() computes the distance (or similarity) between a stored sparse vector field and a query vector, based on the distance metric configured in the vector index (e.g., dot product).
You can use the computed value to sort and return the closest matches.
- Compute the sparse dot product between the query embedding and the
title_embeddingfield using thevector_distance()function. - Store the computed dot product score in the
title_scorefield. - Return the top 10 results sorted by the
title_scorefield in a descending order.
Combine sparse vector search with metadata filtering
Sparse vector search can be combined with metadata filtering by adding afilter() stage to the query: