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

# responseFields

> Fields to include in the search response

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="[&#x22;*&#x22;]" defaultNote="all fields" scope="settings,search" />

The `responseFields` parameter controls which fields are included in the search response.
By default, Algolia includes all fields.

Use this setting to reduce the size of the response.

## Usage

* To reduce the size of individual records in the response,
  use [`attributesToRetrieve`](/doc/api-reference/api-parameters/attributesToRetrieve).
* If `responseFields` is an empty list, the response may return an empty response, except fields that are always included.
* If you include unknown field names, the API returns an error.

<Tip>
  Before using this parameter, check the impact on your search experience.
  For example, if you omit the `hits` field, the response won't include results.
  The UI may also depend on other fields, for example, for pagination.
</Tip>

### Fields you can exclude

* `aroundLatLng`
* `automaticRadius`
* `exhaustive`
* `facets_stats`
* `facets`
* `hitsPerPage`
* `hits`
* `index`
* `length`
* `nbHits`
* `nbPages`
* `offset`
* `page`
* `params`
* `processingTimeMS`
* `queryAfterRemoval`
* `query`
* `serverTimeMS`
* `userData`

### Fields you can't exclude

* `abTestVariantID`
* `cursor`
* `message`
* `warning`
* Fields added by [`getRankingInfo`](/doc/api-reference/api-parameters/getRankingInfo)

## Example

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

      ```dart Dart theme={"system"}
      final response = await client.setSettings(
        indexName: "INDEX_NAME",
        indexSettings: IndexSettings(
          responseFields: [
            "hits",
            "hitsPerPage",
            "nbPages",
            "page",
          ],
        ),
      );
      ```

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

      ```java Java theme={"system"}
      UpdatedAtResponse response = client.setSettings(
        "INDEX_NAME",
        new IndexSettings().setResponseFields(Arrays.asList("hits", "hitsPerPage", "nbPages", "page"))
      );
      ```

      ```js JavaScript theme={"system"}
      const response = await client.setSettings({
        indexName: 'theIndexName',
        indexSettings: { responseFields: ['hits', 'hitsPerPage', 'nbPages', 'page'] },
      });
      ```

      ```kotlin Kotlin theme={"system"}
      var response =
        client.setSettings(
          indexName = "INDEX_NAME",
          indexSettings =
            IndexSettings(responseFields = listOf("hits", "hitsPerPage", "nbPages", "page")),
        )
      ```

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

              'hitsPerPage',

              'nbPages',

              'page',
          ],
          ],
      );
      ```

      ```python Python theme={"system"}
      response = client.set_settings(
          index_name="INDEX_NAME",
          index_settings={
              "responseFields": [
                  "hits",
                  "hitsPerPage",
                  "nbPages",
                  "page",
              ],
          },
      )
      ```

      ```ruby Ruby theme={"system"}
      response = client.set_settings(
        "INDEX_NAME",
        Algolia::Search::IndexSettings.new(response_fields: ["hits", "hitsPerPage", "nbPages", "page"])
      )
      ```

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

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

  <Accordion title="Legacy API clients">
    <CodeGroup>
      ```cs C# theme={"system"}
      IndexSettings settings = new IndexSettings();
      settings.ResponseFields = new List
      {
          "hits",
          "hitsPerPage",
          "nbPages",
          "page"
      };

      index.SetSettings(settings);
      ```

      ```go Go theme={"system"}
      res, err := index.SetSettings(search.Settings{
      	ResponseFields: opt.ResponseFields(
      		"hits",
      		"hitsPerPage",
      		"nbPages",
      		"page",
      	),
      })
      ```

      ```java Java theme={"system"}
      index.setSettings(
        new IndexSettings()
          .setResponseFields(
            Arrays.asList(
              "hits",
              "hitsPerPage",
              "nbPages",
              "page"
            )
          )
      );
      ```

      ```js JavaScript theme={"system"}
      index
        .setSettings({
          responseFields: ["hits", "hitsPerPage", "nbPages", "page"],
        })
        .then(() => {
          // done
        });
      ```

      ```kotlin Kotlin theme={"system"}
      val settings = settings {
          responseFields {
              +Hits
              +HitsPerPage
              +NbPages
              +Page
          }
      }

      index.setSettings(settings)
      ```

      ```php PHP theme={"system"}
      $index->setSettings([
        'responseFields' => [
          'hits',
          'hitsPerPage',
          'nbPages',
          'page'
        ]
      ]);
      ```

      ```python Python theme={"system"}
      index.set_settings({"responseFields": ["hits", "hitsPerPage", "nbPages", "page"]})
      ```

      ```ruby Ruby theme={"system"}
      index.set_settings(
        {
          responseFields: [
            "hits",
            "hitsPerPage",
            "nbPages",
            "page"
          ]
        }
      )
      ```

      ```scala Scala theme={"system"}
      client.execute {
        setSettings of "myIndex" `with` IndexSettings(
          responseFields = Some(Seq(
            "hits",
            "hitsPerPage",
            "nbPages",
            "page"
          ))
        )
      }
      ```

      ```swift Swift theme={"system"}
      let settings = Settings()
        .set(\.responseFields, to: [
          .hits,
          .hitsPerPage,
          .nbPages,
          .page
        ])

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