The resumableQuery method allows you to perform queries that can be resumed to fetch additional results. This is particularly useful for large result sets or when implementing pagination.

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

Payload
ResumableQueryOptions
required
vector | data
number[] | string
required

There are two ways to use the resumableQuery 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.

topK
number
required

The initial number of vectors to retrieve in the query result. The response will be sorted based on the distance metric score.

includeMetadata
boolean

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.

includeVectors
boolean

Whether to include the vector values in the response.

includeData
boolean

Whether to include the data field in the response.

filter
string

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 want to learn more about filtering check: Metadata Filtering

maxIdle
number

Maximum idle time for the resumable query in seconds.

Response

ResumableQueryResponse
Object
required
result
Vector[]
required

The initial query results.

fetchNext
(additionalK: number) => Promise<Vector[]>
required

A function to fetch the next batch of results.

stop
() => Promise<string>
required

A function to stop the resumable query and release resources.

Vector
Object
id
string | number
required

The ID of the resulting vector.

score
number
required

The score of the vector data, calculated based on the distance metric of your index.

vector
number[]

The vector value (if includeVectors is true).

metadata
Record<string, unknown>

The metadata of the vector. This is used to make it easier to identify the vector on queries (if includeMetadata is true).

data
string

The data field (if includeData is true).