search method

  1. @override
Future<List<ScoredChunk>> search(
  1. List<double> query, {
  2. int topK = 5,
  3. double? minScore,
  4. bool where(
    1. Document document
    )?,
})
override

Returns up to topK of the most similar documents an implementation can find for query, best first.

How exact that is depends on the implementation. InMemoryVectorStore compares against every stored document and so returns the true top topK; a store built on an approximate index may return a very good answer rather than the exact one, which is the trade it exists to make.

minScore drops results whose score is below the given value. where restricts the search to documents for which it returns true. Implementations should apply it before scoring where they can, so that filtered documents cost no similarity computation; InMemoryVectorStore does.

Returns an empty list when the store is empty. Throws an ArgumentError when the store is not empty and query does not have the store's embedding dimension, or when topK is less than 1.

Implementation

@override
Future<List<ScoredChunk>> search(
  List<double> query, {
  int topK = 5,
  double? minScore,
  bool Function(Document document)? where,
}) {
  return _inner.search(query, topK: topK, minScore: minScore, where: where);
}