Querying
You can query your vector index for similar vectors. Below, we will learn how to use the SDK to query Dense, Sparse, and Hybrid indexes. You can read more about Sparse Indexes and Hybrid Indexes on our docs.Dense Indexes
We’ll use thequery() method to instruct the SDK to query vectors from Upstash Vector.
The dimension of the query vector must match the dimension of your index.
The score returned from query requests is a normalized value between 0 and 1,
where 1 indicates the highest similarity and 0 the lowest regardless of the
similarity function used.
Sparse Indexes
We can also use thequery() method to instruct the SDK to query our Sparse index, as shown below:
Sparse indexes can only be queried using sparse vectors. If you attempt to pass a regular vector in the query, the SDK will throw an exception.
Hybrid Indexes
Hybrid indexes work the same way; they also use thequery() method to query our index, as shown below:
Embedding Models
Query Data
If your index is configured with one of our embedding models, you can query the index using a simple string, which will be automatically converted into vector embeddings. See the example below:If your index is not configured with an embedding model, this call will throw an exception.