query method

Future<DVSemanticPage<T>> query(
  1. String text, {
  2. DVSearchMode mode = DVSearchMode.keyword,
  3. int limit = 10,
  4. Map<String, String> where = const <String, String>{},
  5. double minScore = 0,
})

Searches the index. where holds conditions on attributesOf's values, pushed into the vector query where the adapter can filter.

minScore is the least cosine a semantic match may have. Everything that shares a word with the query is at some positive angle, so without one a query about one record comes back with the rest trailing after it. In hybrid mode it drops only the semantic tail: what the keyword ranking found stays.

Implementation

Future<DVSemanticPage<T>> query(
  String text, {
  DVSearchMode mode = DVSearchMode.keyword,
  int limit = 10,
  Map<String, String> where = const <String, String>{},
  double minScore = 0,
}) async {
  if (limit < 1) throw ArgumentError.value(limit, 'limit', 'must be positive');
  if (where.isNotEmpty && attributesOf == null) {
    throw ArgumentError.value(
        where, 'where', 'conditions need attributesOf on the index');
  }
  switch (mode) {
    case DVSearchMode.keyword:
      return DVSemanticPage<T>(hits: await _keywordHits(text, limit, where));
    case DVSearchMode.semantic:
      return _semantic(text, limit, where, minScore);
    case DVSearchMode.hybrid:
      return _hybrid(text, limit, where, minScore);
  }
}