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

Choose which fields to return in the API response. This parameters applies to search and browse queries.

This parameter’s main purpose is to limit the response size. For example, in complex queries, retrieving all request parameters in the response’s params field can be undesirable.

Some UI libraries such as InstantSearch may require fields from the response to function properly. Make sure to test the impact on your front-end implementation before restricting response fields in production.

Usage notes

The API returns all fields by default. When using this parameter, it only returns the specified fields. You can also explicitly request all fields by using the * wildcard.

Specifying an empty list or unknown field names is an error.

Here are the fields that can be filtered out:

  • aroundLatLng
  • automaticRadius
  • exhaustive
  • exhaustiveFacetsCount (deprecated, use exhaustive instead)
  • facets
  • facets_stats
  • hits
  • hitsPerPage
  • index
  • length
  • nbHits
  • nbPages
  • offset
  • page
  • params
  • processingTimeMS
  • query
  • queryAfterRemoval
  • userData

Some fields can’t be filtered out:

  • message
  • warning
  • cursor
  • serverUsed
  • indexUsed
  • abTestVariantID
  • timeoutCounts (deprecated, use exhaustive instead)
  • timeoutHits (deprecated, use exhaustive instead)
  • parsedQuery
  • any field triggered by getRankingInfo

Examples

Set default fields to retrieve

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?