Querying Vectors
Now that our database contains data, we want to query it.
There are several ways to query the database, depending on the type of index you have configured.
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 the query()
method to instruct the SDK to query vectors from Upstash Vector.
Sparse Indexes
We can also use the query()
method to instruct the SDK to query our Sparse index, as shown below:
Hybrid Indexes
Hybrid indexes work the same way; they also use the query()
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:
You can read more about Embedding Models on our docs.
Metadata Filtering
Data stored in indexes on Upstash Vector can be populated with metadata, which can then be used for filtering vectors.
Our SDK makes it easy to filter vectors based on their metadata values. Check out the example below:
You can read more about Metadata Filtering on our docs.