API Reference / API Parameters / responseFields
Type: list of strings
Engine default: [*] (all fields)
Parameter syntax
'responseFields' => [
  'response_attribute',
  ...
]

Can be used in these methods:

About this parameter

Fields to include in the API response for search and browse requests.

By default, the API returns all fields. You can use this parameter to reduce the response size by excluding fields from the response.

Your search depends on the hits field. If you omit this field, searches won’t return any results. Your UI might also depend on other fields, for example, for pagination. Before restricting the response size, check the impact on your search experience.

To reduce the size of each returned search result, consider the attributesToRetrieve parameter to reduce the number of attributes included with each result.

If you specify unknown field names, the API returns an error. If you specify an empty list, the API may return an empty response.

You can exclude these fields from the response (by not including them in the responseFields list):

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

Examples

Set fields to include in the API response for all searches

1
2
3
4
5
6
7
8
$index->setSettings([
  'responseFields' => [
    'hits',
    'hitsPerPage',
    'nbPages',
    'page'
  ]
]);
1
2
3
4
5
6
$results = $index->search('query', [
  'responseFields' => [
    'hits',
    'facets'
  ]
]);
Did you find this page helpful?