search method

Future<Iterable<FactDateSchemaQuery>> search(
  1. String term, {
  2. bool isMatchAll = false,
})

Implementation

Future<Iterable<FactDateSchemaQuery>> search(String term,
    {bool isMatchAll = false}) async {
  final tuples = this
      .expand((schema) => schema.dates!.map((date) => Tuple(schema, date)));

  final matches =
      await FullTextSearch<Tuple<IFactSchema, IFactMetaDate>>.ofStream(
    term: term,
    items: Stream.fromIterable(tuples),
    isMatchAll: isMatchAll,
    tokenize: (tuple) => [
      ...tuple.first.tokenize(),
      ...tuple.second.tokenize(),
    ],
  ).execute();
  return [
    ...matches.map((result) {
      final schema = result.result.first;
      final metaDate = result.result.second;
      return FactDateSchemaQuery(
          term, result.matchedTerms.join(" "), schema, metaDate);
    }),
  ];
}