Skip to main content
The sortFacetValuesBy parameter controls the order in which facet values are returned for each facet in the response.
This affects data returned by the facets parameter, but not how values are displayed in the UI.
To customize display order, see Facet value display.

Options

count
Sort facet values by descending count (most frequent values first). The count is the number of records matching the query with that facet value. This is the default.
alpha
Sort facet values alphabetically, from A to Z.

Usage

To control how many facet values are returned, see maxValuesPerFacet.

Examples

Current API clients

Set default sort order for facet values

var response = await client.SetSettingsAsync(
  "ALGOLIA_INDEX_NAME",
  new IndexSettings { SortFacetValuesBy = "alpha" }
);

Change sort order for facet values at query time

var response = await client.SearchSingleIndexAsync<Hit>(
  "ALGOLIA_INDEX_NAME",
  new SearchParams(new SearchParamsObject { Query = "query", SortFacetValuesBy = "count" })
);

Set default sort order for facet values

IndexSettings settings = new IndexSettings();
settings.SortFacetValuesBy = "alpha";

index.SetSettings(settings);

Change sort order for facet values at query time

index.Search(new Query("query")
{
    SortFacetValuesBy = "count"
});
I