Facets REST
When to Use
Use this guide when building a headless or decoupled frontend and you need facet data (values, counts, active states, URLs) in API responses.
Decision
Module: facets_rest
Provides FacetsSerializer — a Views REST display style plugin that includes facet data in the REST response alongside search results.
Pattern
- 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
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
- Wrong: Using
linksorcheckboxwidgets with REST → Right: Use thearraywidget for REST responses. It returns a PHP array structure without HTML rendering.
See Also
- Widgets — ArrayWidget for programmatic output
- Facet Sources — REST display as facet source
- Reference:
web/modules/contrib/facets/modules/facets_rest/