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>{},
})

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

Implementation

Future<DVSemanticPage<T>> query(
  String text, {
  DVSearchMode mode = DVSearchMode.keyword,
  int limit = 10,
  Map<String, String> where = const <String, String>{},
}) 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);
    case DVSearchMode.hybrid:
      return _hybrid(text, limit, where);
  }
}