execute method

Future<List<TermSearchResult<T>>> execute()

Executes a search and applies isMatchAll, or sorting rules, depending on the configuration of this FullTextSearch instance

Implementation

Future<List<TermSearchResult<T>>> execute() async {
  if (term.isNullOrBlank) return [];

  final Stream<TermSearchResult<T>> _results = this.results();
  final FullTextSearch<T> search = this;
  List<TermSearchResult<T>> results;
  if (search.isMatchAll) {
    results = await _results.whereMatchedAll().toList();
  } else {
    results = await _results.toList();
  }
  final sorted = [...results];
  sorted.sort((a, b) => a.compareTo(b));
  results = sorted;
  return limit != null ? [...results.take(limit!)] : [...results];
}