curl \
-X POST 'MEILISEARCH_URL/indexes/books/facet-search' \
-H 'Authorization: Bearer API_KEY' \
-H 'Content-Type: application/json' \
--data-binary '{
"facetQuery": "fiction",
"facetName": "genres",
"filter": "rating > 3"
}'{
"facetHits": [
{
"value": "action",
"count": 273
},
{
"value": "animated",
"count": 15
}
],
"facetQuery": "ac",
"processingTimeMs": 0
}{
"message": "The Authorization header is missing. It must use the bearer authorization method.",
"code": "missing_authorization_header",
"type": "auth",
"link": "https://docs.meilisearch.com/errors#missing_authorization_header"
}{
"message": "Index `movies` not found.",
"code": "index_not_found",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#index_not_found"
}Search for facet values
Search for facet values matching a query within a given facet attribute. Use this to build autocomplete or dropdown UIs for facet filters.
Prerequisite: The facetName attribute must be in the index’s filterableAttributes list.
Facet search will not work without this configuration.
Note: Facet search only considers the first word of facetQuery. Searching for Jane
returns Jane Austen, but searching for Austen does not.
Note: Numeric facet values are not searchable. Convert numbers to strings if you need to search them as facets.
curl \
-X POST 'MEILISEARCH_URL/indexes/books/facet-search' \
-H 'Authorization: Bearer API_KEY' \
-H 'Content-Type: application/json' \
--data-binary '{
"facetQuery": "fiction",
"facetName": "genres",
"filter": "rating > 3"
}'{
"facetHits": [
{
"value": "action",
"count": 273
},
{
"value": "animated",
"count": 15
}
],
"facetQuery": "ac",
"processingTimeMs": 0
}{
"message": "The Authorization header is missing. It must use the bearer authorization method.",
"code": "missing_authorization_header",
"type": "auth",
"link": "https://docs.meilisearch.com/errors#missing_authorization_header"
}{
"message": "Index `movies` not found.",
"code": "index_not_found",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#index_not_found"
}Authorizations
An API key is a token that you provide when making API calls. Read more about how to secure your project.
Include the API key to the Authorization header, for instance:
-H 'Authorization: Bearer 6436fc5237b0d6e0d64253fbaac21d135012ecf1'
If you use a SDK, ensure you instantiate the client with the API key, for instance with JS SDK:
const client = new MeiliSearch({ host: 'MEILISEARCH_URL', apiKey: '6436fc5237b0d6e0d64253fbaac21d135012ecf1' });
Body
Request body for searching facet values
Languages to use for query processing
af, ak, am, ar, az, be, bn, bg, ca, cs, da, de, cy, el, en, eo, et, fi, fr, gu, he, hi, hr, hu, hy, id, it, jv, ja, kn, ka, km, ko, la, lv, lt, ml, mr, mk, my, ne, nl, nb, or, pa, fa, pl, pt, ro, ru, si, sk, sl, sn, es, sr, sv, ta, te, tl, th, tk, tr, uk, ur, uz, vi, yi, zh, zu, afr, aka, amh, ara, aze, bel, ben, bul, cat, ces, dan, deu, cym, ell, eng, epo, est, fin, fra, guj, heb, hin, hrv, hun, hye, ind, ita, jav, jpn, kan, kat, khm, kor, lat, lav, lit, mal, mar, mkd, mya, nep, nld, nob, ori, pan, pes, pol, por, ron, rus, sin, slk, slv, sna, spa, srp, swe, tam, tel, tgl, tha, tuk, tur, ukr, urd, uzb, vie, yid, zho, zul, cmn When true, runs the query on the whole network (all shards covered exactly once).
When false, the query runs locally.
When omitted or null, the default value depends on whether the sharding is enabled for the instance:
- If the instance has sharding enabled (has a leader), defaults to
true. - Otherwise defaults to
false.
It also requires the network experimental feature.
Values: true = use the whole network; false = local, default = see above.
When using the network, the index must exist with compatible settings on all remotes.
Response
Facet values matching the query are returned.
Result of a facet search operation.