- Maintain >98% recall, reducing the likelihood of missing relevant results in applications such as recommendation systems, image search, and semantic search.
- Deliver consistent low latency (p99 < 50 ms). See the benchmarks for details.
- Support large-scale single-collection deployments as well as multi-tenant architectures.
Define a collection schema with a vector field
Define a schema with a vector field and add avector_index():
f32_vector()— Dense float32 embeddings (most common)u8_vector()— Quantized uint8 embeddingsi8_vector()— Signed quantized int8 embeddingsbinary_vector()— Binary embeddings (use withhammingmetric)f32_sparse_vector()— Sparse embeddings (see sparse vector search guide)u8_sparse_vector()— Quantized sparse embeddingsmatrix()— Multi-vector embeddings (see multi-vector search guide)
Perform a k-Nearest Neighbor (kNN) 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 vector field and a query vector, based on the distance metric configured in the vector index (e.g., cosine or Euclidean).
You can use the computed value to sort and return the closest matches.
- Compute the cosine similarity between the query embedding and the
title_embeddingfield using thevector_distance()function. - Store the computed cosine similarity in the
title_similarityfield. - Return the top 10 results sorted by the
title_similarityfield in a descending order.
Combine vector search with metadata filtering
Vector search can be combined with metadata filtering by adding afilter() stage to the query: