Facet search is a dedicated endpoint for searching through the values of a single facet. It is typically used to power auto-complete and type-ahead interfaces on top of filter menus, especially when a facet has too many distinct values to display at once (for example, thousands of brands or authors). If you are new to facets, start with Search with facets and Build faceted navigation. This page focuses on theDocumentation Index
Fetch the complete documentation index at: https://www.meilisearch.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
/facet-search endpoint itself and the edge cases you need to know about before relying on it.
Prerequisites
Before you can search a facet’s values, the attribute must be declared infilterableAttributes. Facet search is enabled by default on every index; you can disable it per index with the facetSearch setting if you do not need it and want to speed up indexing.
Search a facet
Send aPOST request to /indexes/{index_uid}/facet-search with the name of the facet you want to search and the partial string typed by the user:
facetHits array with the matching values and the number of documents that carry each one:
facetQuery with q, filter, and matchingStrategy. See the facet search API reference for the full list of parameters.
Facet search only works on string fields
Internally, Meilisearch stores numbers asfloat64. Floating-point values lack exact decimal precision and can be represented in more than one way, which makes prefix matching on their textual form unreliable. Only string facet values are indexed for facet search.
Facet search only matches the first term of facetQuery
For example, given a author facet that contains "Jane Austen":
facetQuery: "Jane"returnsJane AustenfacetQuery: "Austen"does not returnJane Austen, because the wordAustenis not the start of the stored valuefacetQuery: "Jane Aus"effectively behaves likefacetQuery: "Jane"(the second word is dropped)
q parameter instead and inspect the facetDistribution of the response.
Get exact facet counts
By default, the counts returned by facet search are estimates, which is faster on large indexes. To force exact counts, setexhaustiveFacetCount to true:
Next steps
Search with facets
Configure facets and filter search results
Build faceted navigation
Patterns for category and filter menus
Handle large facet cardinality
Strategies for facets with thousands of values
Facet search API reference
Full list of parameters accepted by
/facet-search