Query
The query method is designed to retrieve the most similar vectors from the index, using the specific distance metric defined for your index. This method supports a variety of options to configure the query to your needs.
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.
Arguments
There are two ways to use the query method. You can either create the vectors on your own and pass directly the vector
field. Or you can pass the data
field and create the embeddings using Upstash Embedding.
The query data/vector that you want to search for in the index.
The total number of the vectors that you want to receive as a query
result. The response will be sorted based on the distance metric score,
and topK
vectors will be returned.
Whether to include the metadata of the vectors in the response. Setting
this true
would be the best practice, since it will make it easier to
identify the vectors.
Whether to include the vector themselves in the response.
Whether to include the data field in the response.
The metadata filtering of the vector. This is used to query your data based on the filters and narrow down the query results. If you wanna learn more about filtering check: Metadata Filtering
Namespace to query. If not set, default namespace is used.
Response
The ID of the resulting vector.
The score of the vector data, calculated based on the distance metric of your index.
The resulting vector (if includeVectors
is set to true)
The metadata of the vector (if includeMetadata
is set to true)
The data of the vector (if includeData
is set to true)
Was this page helpful?