Facet Search
Search for facet values matching a specific query for a facet. When many values exist for a facet, users need to be able to discover non-show values they can select in order to refine their faceted search.
Headers
-
Content-Type string Required
Payload content-type
Value is
application/json
.
Path parameters
-
indexUid string Required
Index Unique Identifier
Body Required
-
facetName string
Query string.
-
facetQuery string
Default value is
""
. -
q string
Additional search parameter. If additional search parameters are set, the method will return facet values that both: - Match the face query - Are contained in the records matching the additional search parameters
Default value is
""
. -
matchingStrategy string
Additional search parameter. If additional search parameters are set, the method will return facet values that both: - Match the face query - Are contained in the records matching the additional search parameters
Default value is
last
. - filter array[string] | string | array[array | string]
One of: Attribute(s) to filter on.
Can be made of 3 syntaxes
- Nested Array:
["something > 1", "genres=comedy", ["genres=horror", "title=batman"]]
- String:
"something > 1 AND genres=comedy AND (genres=horror OR title=batman)"
- Mixed:
["something > 1 AND genres=comedy", "genres=horror OR title=batman"]
_geoRadius({lat}, {lng}, {distance_in_meters}) and _geoBoundingBox([{lat, lng}], [{lat}, {lng}]) built-in filter rules can be used to filter documents within geo shapes.
Attribute(s) used in
filter
should be declared as filterable attributes. See Filtering and Faceted Search.Format of each should match the following pattern:
^[^:]+:[^:]+$
.Attribute(s) to filter on.
Can be made of 3 syntaxes
- Nested Array:
["something > 1", "genres=comedy", ["genres=horror", "title=batman"]]
- String:
"something > 1 AND genres=comedy AND (genres=horror OR title=batman)"
- Mixed:
["something > 1 AND genres=comedy", "genres=horror OR title=batman"]
_geoRadius({lat}, {lng}, {distance_in_meters}) and _geoBoundingBox([{lat, lng}], [{lat}, {lng}]) built-in filter rules can be used to filter documents within geo shapes.
Attribute(s) used in
filter
should be declared as filterable attributes. See Filtering and Faceted Search.Format should match the following pattern:
^[^:]+:[^:]+$
.Attribute(s) to filter on.
Can be made of 3 syntaxes
- Nested Array:
["something > 1", "genres=comedy", ["genres=horror", "title=batman"]]
- String:
"something > 1 AND genres=comedy AND (genres=horror OR title=batman)"
- Mixed:
["something > 1 AND genres=comedy", "genres=horror OR title=batman"]
_geoRadius({lat}, {lng}, {distance_in_meters}) and _geoBoundingBox([{lat, lng}], [{lat}, {lng}]) built-in filter rules can be used to filter documents within geo shapes.
Attribute(s) used in
filter
should be declared as filterable attributes. See Filtering and Faceted Search. - Nested Array:
curl \
-X POST https://example.meilisearch.com:7700/indexes/movies/facet-search \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"facetName":"genres","facetQuery":"Romance"}'
# Headers
Content-Type: application/json
# Payload
{
"facetName": "genres",
"facetQuery": "Romance"
}
{
"facetHits": [
{
"value": "Romance",
"count": 25
},
{
"value": "Romantic",
"count": 3
}
],
"facetQuery": "Rom",
"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"
}