-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Problem
The current "best practice" for facet conditions that are calculated fields (such as a vocabulary or a value from a referenced object) is to create a Zope indexer and use the indexed value as a Solr index.
However, when the referenced object might update, this approach won't be able to follow changes in the referenced object. To solve this with the indexer approach, the referrer content type would need to be reindexed triggered by any change in the referred object.
Proposed Solution
In cases where reindexing on reference changes is not desirable, we prefer an alternative approach:
- Use vocabulary keys as the index value
- Resolve human-readable labels by applying a dictionary lookup on the client side
Vocabulary definitions approach
- Vocabulary-to-field mappings will be defined in the
kitconcept.solr.interfaces.IKitconceptSolrSettings.xmlregistry - The service response will include metadata indicating which vocabulary to use for which field, instructing the client
This follows the same pattern as content type facets: the backend is the single source of truth for configuration.
Benefits
- Avoids cascading reindex operations when referenced objects change
- Simpler data model with stable keys in the index
- Multilingual support potential through multilingual vocabulary lookups (not a current requirement, but enables future development)
Trade-offs
The indexer approach still provides the fastest search results when cascading reindexes are acceptable (as it does not require calling the vocabulary endpoint). This feature provides an alternative when that trade-off is not desirable.
Implementation Plan
- Define a vocabulary registry/configuration format for mapping vocabulary keys to labels
- Implement a helper function to resolve vocabulary labels from keys on the frontend
- Add support for returning which vocabulary to use for which field in the search response
- Update facet rendering logic to apply label lookups when a vocabulary is configured
- Add documentation for when to use each approach (indexer vs. vocabulary lookup)
- Write tests for vocabulary resolution with various edge cases (missing keys, empty values)
- Consider caching strategy for vocabulary definitions on the client side