Query sparse-dense vectors
This page shows you how to query your sparse-dense vectors (hybrid search) and explains how Pinecone ranks hybrid search results.
This feature is in public preview. Consider the current limitations and considerations for serverless indexes, and test thoroughly before using it in production.
Query records with sparse-dense values
To query records with sparse-dense values, use the query
operation, specifying a value for sparse_vector
, which is an object containing the key-value pairs indices
and values
.
The following example queries an index using a sparse-dense vector:
The value of query_response
is like the following:
In order to query an index using sparse values, the index must use the dotproduct metric. Attempting to query any other index with sparse values returns an error.
Query a sparse-dense index with explicit weighting
Because Pinecone views your sparse-dense vector as a single vector, it does not offer a built-in parameter to adjust the weight of a query’s dense part against its sparse part; the index is agnostic to density or sparsity of coordinates in your vectors. You may, however, incorporate a linear weighting scheme by customizing your query vector, as we demonstrate in the function below.
Examples
The following example transforms vector values using an alpha parameter.
The following example transforms a vector using the above function, then queries a Pinecone index.
See also
Was this page helpful?