sortFacetValuesBy
count
Can be used in these methods:
search,
setSettings,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
set_settings,
browse_objects,
search_for_facet_values,
generate_secured_api_key,
add_api_key,
update_api_key
search,
setSettings,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
set_settings,
browse_objects,
search_for_facet_values,
generate_secured_api_key,
add_api_key,
update_api_key
search,
setSettings,
browse,
searchForFacetValues,
generateSecuredApiKey,
addAPIKey,
updateAPIKey
search,
setSettings,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
searchAsync,
setSettingsAsync,
browseAsync,
searchForFacetValues
Search,
SetSettings,
Browse,
SearchForFacetValues,
GenerateSecuredApiKey,
AddApiKey,
UpdateApiKey
Search,
setSettings,
browse,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
Search,
SetSettings,
BrowseObjects,
SearchForFacetValues,
GenerateSecuredAPIKey,
AddAPIKey,
UpdateAPIKey
search,
setSettings,
browse index,
search into facet values,
generateSecuredApiKey,
add key,
update key
About this parameter
Controls how facet values are sorted.
When using facets
, Algolia retrieves a list of matching facet values
for each faceted attribute.
This parameter controls how the facet values are sorted within each faceted attribute.
Usage notes:
-
You can either sort by count (the default, from high to low) or alphabetically
-
The set of returned facet values depends on the maximum number of facet values returned, which depends on the
maxValuesPerFacet
setting. The default is 100 and the max is 1000. Therefore, values with very low frequency could potentially not be returned.
Options:
-
count: Facet values are sorted by decreasing count. The count is the number of records containing this facet value in the results of the query.
-
alpha: Facet values are sorted in alphabetical order, ascending from A to Z.
Examples
Set default sort order for facet values
1
2
3
$index->setSettings([
'sortFacetValuesBy': 'alpha'
]);
Override default sort order for facet values at query time
1
2
3
$results = $index->search('query', [
'sortFacetValuesBy' => "count"
]);