What should I put in AttributesToIndex?

By default all the attributes you push in your records are searchable. The attributeToIndex list allows to restrict the list of attributes the users will be able to search in, to just a few of them.

Take for example this record:

{
  name: 'Algolia',
  description: 'Algolia is a Search as a Service focused on providing the best UX',
  url: 'http://www.algolia.com',
  popularity_score: 42
}

You don't want to search on the URL or the popularity score, only on the text. In this case, your attributesToIndex would be like that:

Additionally to adding the attribute you want to search in, you can easily prioritize each attribute against each other by ordering them in that list. Depending on which attribute has been used to match your records, the engine will give an higher priority/rank to the records where the matches are on top of the attributeToIndex list.

Last updated