Facets REST
When to Use
When building a headless/decoupled frontend and need facet data in API responses.
Decision: Facets REST Sub-Module
Module: facets_rest
Provides FacetsSerializer — a Views REST display style plugin that includes facet data in the REST response alongside search results.
Pattern: Setup
- Enable:
drush en facets_rest - Create a Views REST export display using your Search API index
- Select "Facets Serializer" as the display style
- Create facets for this display's facet source
- Use the
arraywidget for facets used in REST
Pattern: Response Format
The REST response includes a facets key with structured facet data — values, counts, active states, and URLs for each facet item.
Common Mistakes
- Using the
linksorcheckboxwidget for REST facets — Use thearraywidget so the response contains raw structured data instead of rendered HTML.
See Also
- Widgets — ArrayWidget for programmatic output
- Facet Sources — REST display as facet source
- Reference:
modules/facets_rest/