await index.query({ topK: 2, vector: [ ... ]})
/*
{
  matches: [
    {
      id: '6345',
      score: 1.00000012,
      vector: [],
      metadata: {
		sentence: "Upstash is great."
	  }
    },
    {
      id: '1233',
      score: 1.00000012,
      vector: [],
      metadata: undefined
    },
  ],
  namespace: ''
}
*/

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.

Arguments

Payload
QueryOptions
required

Response

QueryResponse
Vector[]
required
await index.query({ topK: 2, vector: [ ... ]})
/*
{
  matches: [
    {
      id: '6345',
      score: 1.00000012,
      vector: [],
      metadata: {
		sentence: "Upstash is great."
	  }
    },
    {
      id: '1233',
      score: 1.00000012,
      vector: [],
      metadata: undefined
    },
  ],
  namespace: ''
}
*/