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.
Only indexes using the dotproduct distance metric support querying sparse-dense vectors.
This feature is in public preview.
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:
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?