Skip to content

Facets

GET /:handle/facets/:field

Search within a facet field’s values. Useful for building typeahead facet filters where users search for specific values within a facet.

ParameterTypeDescription
handlestringIndex handle as configured in config.yaml
fieldstringFacet field name to search within (supports aliases)
ParameterTypeDefaultDescription
qstring""Text to filter facet values (case-insensitive substring).
maxValuesnumber20Maximum number of facet values to return (1–100).
filtersjsonJSON object to narrow the facet context. Values can be a string or array of strings.

The :field parameter and filters keys support field aliases when configured.

{
"field": "country",
"values": [
{ "value": "Scotland", "count": 18 },
{ "value": "Scandinavia", "count": 5 }
]
}
FieldTypeDescription
fieldstringThe facet field name.
valuesFacetValue[]Matching values with counts.
Terminal window
# List all country values
curl "https://search-api-elysia-production.up.railway.app/collections/facets/country"
# Search for countries matching "sc"
curl "https://search-api-elysia-production.up.railway.app/collections/facets/country?q=sc"
# Top 5 regions
curl "https://search-api-elysia-production.up.railway.app/collections/facets/region?maxValues=5"
# Regions within Scotland only
curl "https://search-api-elysia-production.up.railway.app/collections/facets/region?filters=%7B%22country%22%3A%22Scotland%22%7D"

The filters param in the last example decoded: {"country":"Scotland"}

For OR-mode facet filtering (where selecting a value doesn’t reduce its own counts), exclude the current field from filters. See Disjunctive Facets for the full pattern.

Fields inside Elasticsearch nested objects work automatically when nestedPath is configured. The API wraps filters and aggregations in the required nested queries transparently.

StatusCondition
400Invalid JSON in filters
401Missing or invalid bearer token
404Index handle not found