setReplaceSynonymsInHighlight method

AlgoliaQuery setReplaceSynonymsInHighlight({
  1. bool enabled = false,
})

ReplaceSynonymsInHighlight

Whether to highlight and snippet the original word that matches the synonym or the synonym itself.

For example, let’s say you set up home as a synonym for house, and the user types home. Synonym logic will match any record that contains ‘house’ with the synonym ‘home’. This setting will replace the word ‘house’ with ‘home’ in the response. The effect of this is that all highlighting and snippeting will be on the synonym ‘home’. Without this setting, the original word ‘house’ would have been returned and highlighted and snippeted.

Usage notes:

  • When true, highlighting and snippeting will use words from the query rather than the original words from the objects.
  • When false, highlighting and snippeting will always display the original words from the objects.
  • Multiple words can be replaced by a one-word synonym, but not the other way round. For example, if “NYC” and “New York City” are synonyms, searching for “NYC” will replace “New York City” with “NYC” in highlights and snippets, but searching for “New York City” will not replace “NYC” with “New York City” in highlights and snippets.

Source: Learn more

Implementation

AlgoliaQuery setReplaceSynonymsInHighlight({bool enabled = false}) {
  assert(!_parameters.containsKey('replaceSynonymsInHighlight'));
  return _copyWithParameters(
      <String, dynamic>{'replaceSynonymsInHighlight': enabled});
}