setAttributesToSnippet method

AlgoliaQuery setAttributesToSnippet(
  1. List<String> value
)

AttributesToSnippet

List of attributes to snippet, with an optional maximum number of words to snippet.

Usage notes:

  • The number of words can be omitted, and defaults to 10.
  • If not set, no attributes are snippeted.
  • The special value * may be used to snippet all attributes.

Impact on the response:

  • When snippeting is enabled, each hit in the response will contain an additional _snippetResult object (provided that at least one of its attributes is snippeted) with the following fields:
    • value (string): Markup text with occurrences highlighted and optional ellipsis indicators. The tags used for highlighting are specified via highlightPreTag and highlightPostTag. The text used to indicate ellipsis is specified via snippetEllipsisText.
    • matchLevel (string, enum) = {none | partial | full}: Indicates how well the attribute matched the search query.

Source: Learn more

Implementation

AlgoliaQuery setAttributesToSnippet(List<String> value) {
  assert(value.isNotEmpty, 'value can not be empty');
  assert(!_parameters.containsKey('attributesToSnippet'));
  return _copyWithParameters(<String, dynamic>{'attributesToSnippet': value});
}