scoreTerm method

  1. @override
void scoreTerm(
  1. FullTextSearch search,
  2. TermSearchResult term,
  3. Score current
)
override

Inspects a matched term term and appends a score to current. The scores are calculated after all scorers have run, at which point the amount values are summed up, and then the percent multipliers are applied

Implementation

@override
void scoreTerm(FullTextSearch search, TermSearchResult term, Score current) {
  for (final t in term.matchedTokens) {
    switch (t.key) {
      case EqualsMatch.matchKey:
        current += (matchedTokenBoost.times(1.3, "tokenEquals"));
        break;
      case StartsWithMatch.matchKey:
        current += matchedTokenBoost;
        break;
      case ContainsMatch.matchKey:
        current += matchedTokenBoost.times(0.85, "tokenContains");
        break;
      default:
        break;
    }
  }
}