setAttributesToRetrieve method

AlgoliaQuery setAttributesToRetrieve(
  1. List<String> value
)

AttributesToRetrieve

Gives control over which attributes to retrieve and which not to retrieve.

You don’t always need to retrieve a full response that includes every attribute in your index. Sometimes you may only want to receive the most relevant attributes, or exclude attributes used only for internal purposes.

This setting helps reduce your response size and improve performance.

Usage notes:

  • Special Characters:
    • Use * to retrieve all values.
    • Append a dash (-) to an attribute that you do NOT wish to retrieve. Example below. Without prefixing an attribute with -, the attribute will be retrieved.
    • Note that negative attributes (-) only work when using *. For example, “*”, “-title” retrieves every attribute except “title”.
  • objectID is always retrieved, even when not specified.
  • Also note that using negative attributes doesn’t make them unsearchable. If your users make queries that match an attribute not to retrieve, they will still get the same results, but the attribute won’t be part of the response.
  • Attributes listed in unretrievableAttributes will not be retrieved even if requested, unless the request is authenticated with the admin API key.

Source: Learn more

Implementation

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