maxValuesPerFacet
'maxValuesPerFacet' => max_value
Can be used in these methods:
search,
setSettings,
browseObjects,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
set_settings,
browse_objects,
generate_secured_api_key,
add_api_key,
update_api_key
search,
setSettings,
browseObjects,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
set_settings,
browse_objects,
generate_secured_api_key,
add_api_key,
update_api_key
search,
setSettings,
browse,
generateSecuredApiKey,
addAPIKey,
updateAPIKey
search,
setSettings,
browseObjects,
generateSecuredApiKey,
addApiKey,
updateApiKey
Search,
SetSettings,
Browse,
GenerateSecuredApiKey,
AddApiKey,
UpdateApiKey
Search,
setSettings,
browse,
generateSecuredApiKey,
addApiKey,
updateApiKey
Search,
SetSettings,
BrowseObjects,
GenerateSecuredAPIKey,
AddAPIKey,
UpdateAPIKey
search,
setSettings,
browse index,
generateSecuredApiKey,
add key,
update key
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 .
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
]);