> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Index settings

> Customize index names and settings.

## Index names

Index names are derived from the class names.
To customize the index names, pass a string to the `index_name` option.

```ruby Ruby icon=code theme={"system"}
class Contact < ActiveRecord::Base
  include AlgoliaSearch

  algoliasearch(index_name: "MyCustomName") do
    attribute :first_name, :last_name, :email
  end
end
```

## Production and staging indices

To avoid changing your production index,
you can append the current Rails environment to the index name with the `per_environment` option.
This creates separate indices with names following the pattern `MODEL_ENVIRONMENT`.

```ruby Ruby icon=code theme={"system"}
class Contact < ActiveRecord::Base
  include AlgoliaSearch

  algoliasearch(per_environment: true) do
    attribute :first_name, :last_name, :email
  end
end
```

To make it even harder to overwrite your production data,
use different API keys in development and production.
You can restrict access of your development API key to indices with names ending with `_development`.
For more information, see [API keys restrictions](/doc/guides/security/api-keys#api-key-restrictions).

## Basic relevance settings

To set a baseline for your index,
define which attributes should be searchable and define a custom ranking.

```ruby Ruby icon=code theme={"system"}
class Product < ActiveRecord::Base
  include AlgoliaSearch

  algoliasearch do
    # List of attributes used to build an Algolia record
    attributes :title, :subtitle, :description, :likes_count, :thumbnail_url, :release_date

    searchableAttributes ["title", "subtitle", "unordered(description)"]

    customRanking ["desc(likes_count)"]
  end

end
```

For more information, see:

* [Searchable attributes](/doc/guides/managing-results/must-do/searchable-attributes)
* [Custom ranking](/doc/guides/managing-results/must-do/custom-ranking)

## Faceting and filtering

Add all attributes you want to use for [filtering](/doc/framework-integration/rails/searching/search#facets) as facets.

```ruby Ruby icon=code theme={"system"}
class Product < ActiveRecord::Base
  include AlgoliaSearch

  algoliasearch do
    # List of attributes used to build an Algolia record
    attributes :title, :subtitle, :likes_count, :ratings, :categories, :features, :sizes

    # ... Other settings removed for brevity

    attributesForFaceting ["searchable(categories)", "features", "sizes"]
    numericAttributesForFiltering ["likes_count", "equalOnly(ratings)"]
  end

end
```

For more information, see:

* [Faceting](/doc/guides/managing-results/refine-results/faceting)
* [Filtering](/doc/guides/managing-results/refine-results/filtering)

## Synonyms

You can define [regular synonyms](/doc/guides/managing-results/optimize-search-results/adding-synonyms#regular-synonyms)
where all words are considered equivalent.

```ruby Ruby icon=code theme={"system"}
class Contact < ActiveRecord::Base
  include AlgoliaSearch

  algoliasearch do
    attributes :first_name, :email

    synonyms(
      [
        [
          "bob",
          "bobby" \
            "robert"
        ]
      ]
    )
  end
end
```

To define [other types of synonyms](/doc/guides/managing-results/optimize-search-results/adding-synonyms),
directly call the [`saveSynonyms`](/doc/libraries/sdk/v1/methods/save-synonyms)
method on the API client.

## Sync your settings with Algolia

By default, your settings will be synced with Algolia.

## Turn off automatic syncing

If you turn off automatic syncing, make sure to manually send updates to Algolia whenever you change your settings.

```ruby Ruby icon=code theme={"system"}
class Musician < ActiveRecord::Base
  include AlgoliaSearch

  algoliasearch(check_settings: false) do
    searchableAttributes ["name", "band"]
  end
end
```

## Apply all settings

To send settings updates for all indices, use the `set_all_settings` rake command.
It sends updates to your primary indices, your replicas, and any indices you added with `add_index`.

Consider adding this command to your deployment pipeline,
especially if you turned off automatic settings updates.

```sh Command line icon=square-terminal theme={"system"}
rake algoliasearch:set_all_settings
```
