fts5TermFrequency function

double fts5TermFrequency(
  1. String document,
  2. String query
)

Per-document term-frequency score useful as a relevance signal in ORDER BY. The result is the sum over query terms of their raw occurrence counts in document (after the same tokenization used by fts5Match). Phrases count as 1 per non-overlapping occurrence; prefix terms count occurrences of every matching token. Documents that don't match the query at all score 0.

Implementation

double fts5TermFrequency(String document, String query) {
  final node = parseFts5Query(query);
  if (node == null) return 0.0;
  final tokens = tokenizeFts(document);
  return _scoreNode(node, tokens);
}