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

# unretrievableAttributes

> Attributes to exclude from the records in search results

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="no excluded attributes" scope="settings" />

The `unretrievableAttributes` setting specifies attributes in your records to exclude from search results.
This can help protect sensitive information,
such as internal metrics or access controls,
which may be used for ranking or filtering but shouldn't be visible to end users.

<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>

## Usage

* Attribute names are case-sensitive.
* This setting is ignored if the query is authenticated with the **Admin API key**.

## Example

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

      ```dart Dart theme={"system"}
      final response = await client.setSettings(
        indexName: "INDEX_NAME",
        indexSettings: IndexSettings(
          unretrievableAttributes: [
            "total_number_of_sales",
          ],
        ),
      );
      ```

      ```go Go theme={"system"}
      response, err := client.SetSettings(client.NewApiSetSettingsRequest(
        "INDEX_NAME",
        search.NewEmptyIndexSettings().SetUnretrievableAttributes(
          []string{"total_number_of_sales"})))
      if err != nil {
        // handle the eventual error
        panic(err)
      }
      ```

      ```java Java theme={"system"}
      UpdatedAtResponse response = client.setSettings(
        "INDEX_NAME",
        new IndexSettings().setUnretrievableAttributes(Arrays.asList("total_number_of_sales"))
      );
      ```

      ```js JavaScript theme={"system"}
      const response = await client.setSettings({
        indexName: 'theIndexName',
        indexSettings: { unretrievableAttributes: ['total_number_of_sales'] },
      });
      ```

      ```kotlin Kotlin theme={"system"}
      var response =
        client.setSettings(
          indexName = "INDEX_NAME",
          indexSettings = IndexSettings(unretrievableAttributes = listOf("total_number_of_sales")),
        )
      ```

      ```php PHP theme={"system"}
      $response = $client->setSettings(
          'INDEX_NAME',
          ['unretrievableAttributes' => [
              'total_number_of_sales',
          ],
          ],
      );
      ```

      ```python Python theme={"system"}
      response = client.set_settings(
          index_name="INDEX_NAME",
          index_settings={
              "unretrievableAttributes": [
                  "total_number_of_sales",
              ],
          },
      )
      ```

      ```ruby Ruby theme={"system"}
      response = client.set_settings(
        "INDEX_NAME",
        Algolia::Search::IndexSettings.new(unretrievable_attributes: ["total_number_of_sales"])
      )
      ```

      ```scala Scala theme={"system"}
      val response = Await.result(
        client.setSettings(
          indexName = "INDEX_NAME",
          indexSettings = IndexSettings(
            unretrievableAttributes = Some(Seq("total_number_of_sales"))
          )
        ),
        Duration(100, "sec")
      )
      ```

      ```swift Swift theme={"system"}
      let response = try await client.setSettings(
          indexName: "INDEX_NAME",
          indexSettings: IndexSettings(unretrievableAttributes: ["total_number_of_sales"])
      )
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Legacy API clients">
    <CodeGroup>
      ```cs C# theme={"system"}
      IndexSettings settings = new IndexSettings
      {
        UnretrievableAttributes = new List { "total_number_of_sales" }
      };

      index.SetSettings(settings);
      ```

      ```go Go theme={"system"}
      res, err := index.SetSettings(search.Settings{
      	UnretrievableAttributes: opt.UnretrievableAttributes(
      		"total_number_of_sales",
      	),
      })
      ```

      ```java Java theme={"system"}
      index.setSettings(
              new IndexSettings().setUnretrievableAttributes(Collections.singletonList(
                      "total_number_of_sales"
              ))
      );
      ```

      ```js JavaScript theme={"system"}
      index
        .setSettings({
          unretrievableAttributes: ["total_number_of_sales"],
        })
        .then(() => {
          // done
        });
      ```

      ```kotlin Kotlin theme={"system"}
      val settings = settings {
          unretrieveableAttributes {
              +"total_number_of_sales"
          }
      }

      index.setSettings(settings)
      ```

      ```php PHP theme={"system"}
      $index->setSettings([
        'unretrievableAttributes' => [
          'total_number_of_sales'
        ]
      ]);
      ```

      ```python Python theme={"system"}
      index.set_settings({"unretrievableAttributes": ["total_number_of_sales"]})
      ```

      ```ruby Ruby theme={"system"}
      index.set_settings(
        {
          unretrievableAttributes: [
            "total_number_of_sales"
          ]
        }
      )
      ```

      ```scala Scala theme={"system"}
      client.execute {
        setSettings of "myIndex" `with` IndexSettings(
          unretrievableAttributes = Some(Seq(
            "total_number_of_sales"
          ))
        )
      }
      ```

      ```swift Swift theme={"system"}
      let settings = Settings()
        .set(\.unretrievableAttributes, to: [
          "total_number_of_sales"
        ])

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