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

# searchableAttributes

> List of attributes in which to search and in what order of priority

export const Setting = ({type, default: defaultValue, defaultNote, scope, min, max, formerly}) => {
  const renderedDefault = defaultValue === '' ? '""' : defaultValue;
  const renderedNote = defaultNote ? `(${defaultNote})` : '';
  return <ul>
      <li><strong>Type:</strong> <code>{type}</code></li>
      <li><strong>Default:</strong> <code>{renderedDefault}</code>{renderedNote}</li>
      {min && <li><strong>Min:</strong> <code>{min}</code></li>}
      {max && <li><strong>Max:</strong> <code>{max}</code></li>}
      <li><strong>Scope:</strong> <a href="/doc/api-reference/api-parameters"><code>{scope}</code></a></li>
      {formerly && <li>
          <strong>Deprecated name:</strong> <code>{formerly}</code>
        </li>}
    </ul>;
};

<Setting type="list<string>" default="[]" defaultNote="all string attributes" scope="settings" formerly="attributesToIndex" />

This parameter determines which attributes Algolia searches and in which order of relevance.
It's one of the most important settings for controlling search precision and ranking:

* Limits the attributes Algolia uses to find matches.
  Avoid searching attributes like URLs or image paths.

* Attributes listed first are more important for ranking.
  Records matching higher-priority attributes rank higher than those matching lower-priority attributes.

To learn more, see [Searchable attributes](/doc/guides/managing-results/must-do/searchable-attributes).

<Tip>
  Updating the `searchableAttributes` parameter rebuilds your index.
  If you need near real-time indexing, avoid changing the index configuration during high-traffic times.
</Tip>

## Usage

### Default

If unset or set to an empty list, Algolia searches all string-based attributes.
This turns off the [Attributes](/doc/guides/managing-results/relevance-overview/in-depth/ranking-criteria#attribute) ranking criterion.

### Priority order

Attributes are searched in the order they appear.
Earlier attributes have higher ranking weight.
By default, matches at the beginning of an attribute rank higher.
To ignore the position of matches within an attribute,
use [modifiers](#modifiers).

### Attributes with the same priority

To make two attributes [equally important](/doc/guides/managing-results/must-do/searchable-attributes/how-to/configuring-searchable-attributes-the-right-way#attribute-order),
include them in the same comma-separated string.
Attributes with the same priority as others are always [`unordered`](#modifiers).

### Nested attributes

You can specify nested attributes, such as, `categories.lvl0.label`.
If you specify a parent attribute, all nested attributes are searchable.

### Case-sensitive

Attribute names are case-sensitive.

<Info>
  There's no hard limit on the number of attributes you can include,
  but adding too many can slow down [`getSettings`](/doc/rest-api/search/get-settings) operations
  and degrade performance in the Algolia dashboard.
</Info>

### Modifiers

<ParamField path="unordered">
  Ignores the position of a match within the attribute.
  By default, matches at the beginning of an attribute rank higher.
  Setting an attribute as unordered treats all matches within the attribute equally.

  * Attributes with the same priority at the same level are always unordered
  * The default differs between API (ordered) and Algolia dashboard (unordered).
</ParamField>

## Example

The following configuration:

* Gives equal priority to `title` and `alternative_title`
* Ranks `author` next
* Applies `unordered` to `text` so that the match position doesn't influence ranking
* Searches only the `personal` field within the nested `emails` attribute

<AccordionGroup>
  <Accordion title="Current API clients" defaultOpen="true">
    <CodeGroup>
      ```cs C# theme={"system"}
      var response = await client.SetSettingsAsync(
        "INDEX_NAME",
        new IndexSettings
        {
          SearchableAttributes = new List<string>
          {
            "title,alternative_title",
            "author",
            "unordered(text)",
            "emails.personal",
          },
        }
      );
      ```

      ```dart Dart theme={"system"}
      final response = await client.setSettings(
        indexName: "INDEX_NAME",
        indexSettings: IndexSettings(
          searchableAttributes: [
            "title,alternative_title",
            "author",
            "unordered(text)",
            "emails.personal",
          ],
        ),
      );
      ```

      ```go Go theme={"system"}
      response, err := client.SetSettings(client.NewApiSetSettingsRequest(
        "INDEX_NAME",
        search.NewEmptyIndexSettings().SetSearchableAttributes(
          []string{"title,alternative_title", "author", "unordered(text)", "emails.personal"})))
      if err != nil {
        // handle the eventual error
        panic(err)
      }
      ```

      ```java Java theme={"system"}
      UpdatedAtResponse response = client.setSettings(
        "INDEX_NAME",
        new IndexSettings().setSearchableAttributes(Arrays.asList("title,alternative_title", "author", "unordered(text)", "emails.personal"))
      );
      ```

      ```js JavaScript theme={"system"}
      const response = await client.setSettings({
        indexName: 'theIndexName',
        indexSettings: {
          searchableAttributes: ['title,alternative_title', 'author', 'unordered(text)', 'emails.personal'],
        },
      });
      ```

      ```kotlin Kotlin theme={"system"}
      var response =
        client.setSettings(
          indexName = "INDEX_NAME",
          indexSettings =
            IndexSettings(
              searchableAttributes =
                listOf("title,alternative_title", "author", "unordered(text)", "emails.personal")
            ),
        )
      ```

      ```php PHP theme={"system"}
      $response = $client->setSettings(
          'INDEX_NAME',
          ['searchableAttributes' => [
              'title,alternative_title',

              'author',

              'unordered(text)',

              'emails.personal',
          ],
          ],
      );
      ```

      ```python Python theme={"system"}
      response = client.set_settings(
          index_name="INDEX_NAME",
          index_settings={
              "searchableAttributes": [
                  "title,alternative_title",
                  "author",
                  "unordered(text)",
                  "emails.personal",
              ],
          },
      )
      ```

      ```ruby Ruby theme={"system"}
      response = client.set_settings(
        "INDEX_NAME",
        Algolia::Search::IndexSettings.new(
          searchable_attributes: ["title,alternative_title", "author", "unordered(text)", "emails.personal"]
        )
      )
      ```

      ```scala Scala theme={"system"}
      val response = Await.result(
        client.setSettings(
          indexName = "INDEX_NAME",
          indexSettings = IndexSettings(
            searchableAttributes = Some(Seq("title,alternative_title", "author", "unordered(text)", "emails.personal"))
          )
        ),
        Duration(100, "sec")
      )
      ```

      ```swift Swift theme={"system"}
      let response = try await client.setSettings(
          indexName: "INDEX_NAME",
          indexSettings: IndexSettings(searchableAttributes: [
              "title,alternative_title",
              "author",
              "unordered(text)",
              "emails.personal",
          ])
      )
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Legacy API clients">
    <CodeGroup>
      ```cs C# theme={"system"}
      IndexSettings settings = new IndexSettings
      {
          SearchableAttributes = new List
          {
            "title,alternative_title",
            "author",
            "unordered(text)",
            "emails.personal"
          }
      };

      index.SetSettings(settings);
      ```

      ```go Go theme={"system"}
      res, err := index.SetSettings(search.Settings{
      	SearchableAttributes: opt.SearchableAttributes(
      		"title,alternative_title",
      		"author",
      		"unordered(text)",
      		"emails.personal",
      	),
      })
      ```

      ```java Java theme={"system"}
      index.setSettings(
        new IndexSettings().setSearchableAttributes(Arrays.asList(
          "title,alternative_title",
          "author",
          "unordered(text)",
          "emails.personal"
        ))
      );
      ```

      ```js JavaScript theme={"system"}
      index
        .setSettings({
          searchableAttributes: [
            "title,alternative_title",
            "author",
            "unordered(text)",
            "emails.personal",
          ],
        })
        .then(() => {
          // done
        });
      ```

      ```kotlin Kotlin theme={"system"}
      val settings = settings {
          searchableAttributes {
              +"title,alternativeTitle"
              +"author"
              +Unordered("text")
              +"emails.personal"
          }
      }

      index.setSettings(settings)
      ```

      ```php PHP theme={"system"}
      $index->setSettings([
        'searchableAttributes' => [
          'title,alternative_title',
          'author',
          'unordered(text)',
          'emails.personal'
        ]
      ]);
      ```

      ```python Python theme={"system"}
      index.set_settings(
          {
              "searchableAttributes": [
                  "title,alternative_title",
                  "author",
                  "unordered(text)",
                  "emails.personal",
              ]
          }
      )
      ```

      ```ruby Ruby theme={"system"}
      index.set_settings(
        {
          searchableAttributes: [
            "title,alternative_title",
            "author",
            "unordered(text)",
            "emails.personal"
          ]
        }
      )
      ```

      ```scala Scala theme={"system"}
      client.execute {
        setSettings of "myIndex" `with` IndexSettings(
          searchableAttributes = Some(Seq(
            SearchableAttributes.attributes("title", "alternative_title")
            SearchableAttributes.attribute("author")
            SearchableAttributes.unordered("text")
            SearchableAttributes.attribute("emails.personal")
          ))
        )
      }
      ```

      ```swift Swift theme={"system"}
      let settings = Settings()
        .set(\.searchableAttributes, to: [
          "title,alternative_title",
          "author",
          .unordered("text"),
          "emails.personal"
        ])

      index.setSettings(settings) { result in
        if case .success(let response) = result {
          print("Response: \(response)")
        }
      }
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>
