When setting up and configuring your index, the first step is to decide which attributes you want to use for searching. When you create an index, all attributes in all your records are searchable by default. This means you can perform searches straight away without configuring anything. However, to enhance search relevance and exclude unnecessary results, you should specify which attributes should be searchable.

  • An example of a useful searchable attribute is the name of a product.
  • An example of an attribute that isn’t useful for searching is a URL. Since users seldom search for URLs, exclude them from the searchable attributes list. However, you can still use image URLs to display images in the results.

For example, on a recipes website it makes sense to make title, ingredients, and comments searchable, and exclude images. You can still use non-searchable attributes for display or filtering.

Attributes to include

The following attributes are commonly included (searchable):

  • Descriptive attributes: name, description, brand, list of actors in a film, list of features in a computer.
  • Filters: color, brand, size.
  • Keywords and tags.
  • Valuable data like telephone numbers, SKU, ISBN, and other identifying attributes.

Attributes to exclude

These are often excluded (not searchable):

  • For display only: image and other URLs, price, brand logos, SKU.
  • Short descriptions are meant to be displayed, not searched since they usually summarize what’s in a longer description.
  • For information only: not yet available, just released, on promotion.
  • For ranking only: most sales, most viewed, highest rated.

Set searchable attributes

Specify searchable attributes from the dashboard or API.

Set searchable attributes in the Algolia dashboard

  1. Go to the Algolia dashboard and select your Algolia application.

  2. On the left sidebar, select Search.

  3. Select your Algolia index:

  4. On the Configuration tab, select Searchable attributes.

  5. Click Add a Searchable Attribute and type or select an attribute from the list.

  6. Change the order of attributes by dragging them up or down in the Searchable attributes list. To make two attributes equally important, when you add a new attribute, type the attributes directly as a comma-separated list—for example, title, comments.

  7. Save your changes.

Set searchable attributes with the API

To make certain attributes searchable, include them in the searchableAttributes setting when configuring your index with the setSettings method.

To configure the order of searchable attributes:

  • The higher in the list you place an attribute, the higher matches within that attribute will rank in search results.
  • If you want two attributes to have the same priority, include them on the same level, separated by a comma.

In the first example, title and comments have the same priority. In the second example, matches in the title attribute rank before matches in the comments attribute.

See also