Flutter: queryVectors

Searches the scoped index for the vectors most similar to queryVector. topK limits the number of matches returned. filter restricts the search to vectors whose metadata matches the given expression. Set returnDistance and returnMetadata to include the distance scores and metadata in the result.

Examples

Query vectors

final index = supabase.storage.vectors
    .from('embeddings')
    .index('documents');

final VectorQueryResult result = await index.queryVectors(
  queryVector: [0.1, 0.2, 0.3],
  topK: 5,
  returnDistance: true,
  returnMetadata: true,
);

for (final match in result.matches) {
  print('${match.key}: ${match.distance}');
}

Query with a metadata filter

final index = supabase.storage.vectors
    .from('embeddings')
    .index('documents');

final result = await index.queryVectors(
  queryVector: [0.1, 0.2, 0.3],
  topK: 10,
  filter: {'category': 'docs'},
  returnMetadata: true,
);