🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
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 facet values to return for each facet in a regular search.

To set the number of facet values returned in a regular search use maxValuesPerFacet but to set the maximum number of hits to return 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 .

Examples

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.

1
2
3
$index->setSettings([
  '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.

1
2
3
$results = $index->search('query', [
  'maxValuesPerFacet' => 20
]);
Did you find this page helpful?