Configuring your search index

The current configuration for your search index is displayed when you click the "configure" tab. When you create an index using the search index wizard, it will be configured with some default settings that you can customize to meet your needs.

The most common settings that you may want to change are searchableAttributes, customRanking and attributesForFaceting. On this page we'll give you a quick overview of these settings. Information about all of the settings can be found in the Algolia documentation.

For an example of editing the search index configuration see updating the configuration.

Searchable attributes

As a minimum you should configure some properties as "searchable attributes". This limits the scope of a search and creates an order of priority to improve the relevance of your search results. The order in which you list searchable attributes determines their search priority.

If no searchable attributes are defined, then all properties will be searched.

In the following example title, description and content.text are defined as searchableAttributes. title will have a higher priority than description, while content.text will have the lowest priority.

{
  "searchableAttributes": [
    "title",
    "description",
    "content.text"
  ]
}

For more information about search attributes see the Algolia reference documentation and guide.

Custom Ranking

A custom ranking allows you to specify which content is most relevant to your users and should always be set. It's used to determine the sort order when there is no search query (no keywords and no filters).

On an index of blog articles it could be the publish date, the number of comments, or a boolean to flag "featured" posts. To rank by date in descending order you would use the following:

{
   "customRanking": [
    "desc(date)"
  ]
}

In most cases, only number or boolean properties should be used for a custom ranking. In the case of date, you can update your webhook payload to convert a human readable date into a unix timestamp. See search example part 2, optimizing the record size to see how to do this in your custom payload.

For more information about custom ranking see the Algolia reference documentation and guide.

Facets

Facets let you create categories from a chosen group of attributes, to allow your end users to refine their search. For example, on an index of blog articles, useful facets might be tags and author name.

Algolia calculates how many results there are for each facet and allows you to display facets and facet counts in the UI so that the user can filter results.

To make use of faceting, you need to enable it on a per-attribute basis with the attributesForFaceting parameter. In the following example tags is made a searchable facet, allowing a user to search the facet values, while authors.name is a standard facet.

{
  "attributesForFaceting": [
   "searchable(tags)",
   "authors.name"
  ]
}

For more information about facets see the Algolia reference documentation and guide.

Algolia API parameters.

results matching ""

    No results matching ""