API Reference / API Parameters / responseFields
Feb. 26, 2019

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 the response will contain. Applies to search and browse queries.

This parameter is mainly intended to limit the response size. For example, in complex queries, echoing of request parameters in the response’s params field can be undesirable.

Usage notes:

  • By default, all fields are returned. If this parameter is specified, only the fields explicitly listed will be returned, unless * is used, in which case all fields are returned. Specifying an empty list or unknown field names is an error.

  • List of fields that can be filtered out:

    • aroundLatLng
    • automaticRadius
    • exhaustiveFacetsCount
    • facets
    • facets_stats
    • hits
    • hitsPerPage
    • index
    • length
    • nbHits
    • nbPages
    • offset
    • page
    • params
    • processingTimeMS
    • query
    • queryAfterRemoval
    • userData
  • List of fields that cannot be filtered out:

    • message
    • warning
    • cursor
    • serverUsed
    • indexUsed
    • abTestVariantID
    • timeoutCounts (deprecated, please use exhaustiveFacetsCount instead)
    • timeoutHits (deprecated, please use exhaustiveFacetsCount instead)
    • parsedQuery
    • all fields 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?