Use this file to discover all available pages before exploring further.
Faceted navigation displays filter options alongside the number of matching documents, letting users progressively refine their search. This is the pattern behind product sidebars on ecommerce sites, where users can click “Electronics (42)” or “Books (18)” to narrow results.This guide walks through the full pattern: configuring filterable attributes, requesting facet distributions, and building an interactive UI.
Wait for the settings task to complete before searching.
If an attribute passed to facets has not been added to filterableAttributes, Meilisearch silently ignores it. No error is raised; the attribute simply will not appear in the facetDistribution response. If a facet is missing from your UI, double-check that it is declared as a filterable attribute.
The facetDistribution tells you exactly which values exist and how many documents match each one. The facetStats object provides minimum and maximum values for numeric facets, useful for building range sliders.
facetStats only considers values stored as JSON numbers. String values are ignored, even when the string contains a numeric value such as "42". If you expect min/max for a given facet and the object is missing, confirm that the underlying field is indexed as a number rather than a string.
The response updates both the hits and the facetDistribution to reflect the active filter. This means the facet counts adjust dynamically, showing users how many results remain for each option.
Users often select multiple facet values. Combine them using AND and OR operators:
curl \ -X POST 'MEILISEARCH_URL/indexes/books/search' \ -H 'Content-Type: application/json' \ --data-binary '{ "q": "classic", "filter": "genres = Classics AND language = English AND rating >= 4", "facets": ["genres", "language", "rating"] }'
Use AND to require all conditions (narrow results) and OR to match any condition (broaden results within a facet group). See the filter expression syntax reference for the full list of operators:
"filter": "(genres = Classics OR genres = Fiction) AND language = English"
By default, Meilisearch returns up to 100 distinct values per facet in the facetDistribution object. If your UI only displays the top 10 or 20 options, lower maxValuesPerFacet to match what you actually render:
Setting maxValuesPerFacet to a high value might negatively impact performance. Raising it only makes sense when you genuinely need to surface a large number of facet values at once.