Overview
TheVectorQuery class represents a vector search query for a specific field in a collection. It can be constructed using either a document ID to look up its vector, or an explicit query vector. You can optionally include index-specific query parameters to control search behavior.
Constructor
Parameters
Name of the vector field to query.
Document ID to fetch vector from. Exactly one of
id or vector should be provided.Explicit query vector (list of floats). Exactly one of
id or vector should be provided.Index-specific query parameters to control search behavior. Use HnswQueryParam for HNSW indexes or IVFQueryParam for IVF indexes.
Methods
has_id()
Check if the query is based on a document ID. Returns:bool - True if id is set, False otherwise.
has_vector()
Check if the query contains an explicit vector. Returns:bool - True if vector is non-empty, False otherwise.
Examples
Query by document ID
Query by explicit vector
Query with HNSW parameters
Query with IVF parameters
Notes
The
param field allows you to fine-tune search behavior based on your index type. Different index types support different query parameters.