API Reference / API Parameters / maxValuesPerFacet
Type: integer
Engine default: 100
Parameter syntax
'maxValuesPerFacet' => max_value

Can be used in these methods:

About this parameter

The maximum number of values to return for each facet.

If you have a facet with many values, adjusting maxValuesPerFacet focuses the search experience on the most relevant facets and helps users find what they want.

For example, on a luxury clothing website with an extensive list of shoe brands, searching for “shoe” will bring up the top 100 brand facets by default To only show the most relevant brands, reduce maxValuesPerFacet to a smaller number, such as 15. This way, only the top 15 brands will appear as facet values.

Similarly, for a book retailer site, where facets like author and genre can have numerous values, set maxValuesPerFacet to 50 so that only the top 50 authors and genres show in the facet display.

To set the number of facet values returned use maxValuesPerFacet but to set the maximum hits returned in a searchForFacetValues, use maxFacetHits, instead.

Usage notes

For performance reasons, the maximum value for maxValuesPerFacet is 1,000. You can set it higher but the engine will interpret it as 1,000 .


Set the default number of facet values to retrieve

For example, if an ecommerce site has 443 different phone brands, and a user searches for “phone”, this default setting will only return the top 100 brands.

  'maxValuesPerFacet' => 100

Set the maximum number of facet values for the current query

This search setting will override the default maxValuesPerFacet but just for the current search. For example, on an ecommerce site, if a user searches for “iphone”, this setting will only return the top 20 iPhone brands.

$results = $index->search('query', [
  'maxValuesPerFacet' => 20
Did you find this page helpful?