Benjamin Habegger created OAK-12231:
---------------------------------------

             Summary: Mixin type addition/removal does not trigger index update 
in FulltextIndexEditor
                 Key: OAK-12231
                 URL: https://issues.apache.org/jira/browse/OAK-12231
             Project: Jackrabbit Oak
          Issue Type: Bug
          Components: indexing, oak-search
            Reporter: Benjamin Habegger


When a mixin type is added to or removed from an existing node, 
fulltext/property indexes whose indexing rules are scoped to that mixin type 
are not correctly updated.

h3. Root Cause

In {{FulltextIndexEditor}}, the {{enter()}} method evaluates {{indexingRule}} 
against only the {{after}} node state:

*Mixin removal:*
- {{indexingRule = null}} (after state has no matching rule)
- {{markPropertyChanged("jcr:mixinTypes")}} is a no-op because {{isIndexable() 
= false}}
- {{propertiesChanged}} stays false
- {{leave()}} skips {{addOrUpdate()}} — stale document remains in the index, 
never deleted

*Mixin addition:*
- {{indexingRule}} is correctly set from {{after}} state
- But {{markPropertyChanged("jcr:mixinTypes")}} only sets {{propertiesChanged = 
true}} if {{jcr:mixinTypes}} is explicitly listed in the rule's {{propDefns}}
- For rules that index content properties only (not primaryType/mixinTypes), 
{{isIndexed("jcr:mixinTypes")}} returns false
- Node is not indexed

h3. Proposed Fix

In {{enter()}}, evaluate the indexing rule for *both* {{before}} and {{after}} 
states. If the applicable rule changed (including null ↔ non-null transitions):
- Before had a rule, after does not: issue a {{deleteDocuments(path)}} call
- Before had no rule, after does: force {{propertiesChanged = true}} to trigger 
{{addOrUpdate()}}

h3. Test Coverage

New tests in {{oak-search}} (unit, via {{FulltextIndexEditor}} directly) and in 
{{oak-lucene}} / {{oak-search-elastic}} (integration via JCR API using 
{{addMixin}} / {{removeMixin}}).




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to