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
        
        
          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 fetched.
When using facets, Algolia retrieves a list of matching facet values
for each faceted attribute.
This parameter controls in which order the facet values are retrieved within each faceted attribute.
This parameter doesn’t control or impact how facet values are displayed on the UI. See facet value display to control how facet values should be displayed.
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
maxValuesPerFacetsetting. The default is 100 and the max is 1000. Therefore, values with very low frequency could potentially not be returned. - 
    
For example:
- With 
maxValuesPerFacetset to2 - With 
sortFacetValuesset toalpha - And with the facet “brand” containing the values 
["Amazon", "Apple", "Facebook", "Google"] - When using “facets” Algolia would retrieve the first 2 values in alphabetical order, so 
["Amazon", "Apple"]if all values are present in the result set. 
 - With 
 
Options
 | 
      Facet values are sorted by decreasing count. The count is the number of records containing this facet value in the results of the query.  | 
    
 | 
      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"
]);