Problem/Motivation
I'm using the following setup:
- Drupal 10.6.9
- Search API 1.40 (Database backend)
- Facets
- Facets Exposed Filters
- Viewfield module
- Content Moderation enabled on Taxonomy Terms (revisionable taxonomy)
I have a taxonomy structure like this:
Parent Taxonomy Term
↓
Paragraph (contains a Viewfield)
↓
Search API View (with contextual filter = Parent Term ID)
↓
Displays Child Taxonomy Terms
The child taxonomy terms contain several fields (Product Type, Price, etc.).
These fields are configured as exposed filters using the Facets Exposed Filters module.
The View is embedded through the Viewfield formatter and reused across multiple taxonomy pages.
Editors have permission to view the latest revisions of taxonomy terms, while anonymous users should only see published content.
I'm looking for the recommended Drupal/Search API approach for supporting:
- Editors → Latest revision for both results and facet values
- Anonymous users → Published revision for both results and facet values
without duplicating Views if possible.
Steps to reproduce
- Create a revisionable taxonomy vocabulary with Content Moderation enabled.
- Create child taxonomy terms containing fields such as:
- Product Type
- Price
- Create a Search API index using the Database backend.
- Create a View based on the Search API index.
- Add Facets Exposed Filters for the taxonomy fields.
- Embed the View using the Viewfield module inside a paragraph referenced by a taxonomy term.
- Publish a child taxonomy term with:
Product Type= A
- Edit the same child taxonomy term and create a new draft revision:
Product Type = B
(do not publish)
- Visit the taxonomy page as an editor.
Current result
- Search results and Facet exposed filter values showing only the last published values.
- Example:
- Published revision: Product Type = A
- Draft revision: Product Type = B
- Results and Facet filter should display "B"
Expected result
When a user has permission/role to view the latest revision:
- Search results should display the latest revision.
- Facet values should also be generated from the latest revision.
- Both results and exposed filters should remain consistent.
Anonymous users should continue to see both results and facet values generated from the last published revision.
Question
What is the recommended architecture for supporting Content Moderation with Search API + Facets Exposed Filters where:
- Users with specific role see latest revision data for both search results and facet values.
- Anonymous users see last published data.
Is maintaining separate Search API indexes (published and preview) the recommended approach, or is there any way that allows Facets to build aggregations from the latest revision without duplicating Views?
Comments
Comment #2
kanchamk commented