[
https://issues.apache.org/jira/browse/OAK-12244?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Thomas Mueller reassigned OAK-12244:
------------------------------------
Assignee: Thomas Mueller
> [oak-search] Index not updated when node gains or loses a mixin type at
> runtime
> -------------------------------------------------------------------------------
>
> Key: OAK-12244
> URL: https://issues.apache.org/jira/browse/OAK-12244
> Project: Jackrabbit Oak
> Issue Type: Bug
> Components: oak-search
> Reporter: Benjamin Habegger
> Assignee: Thomas Mueller
> Priority: Major
>
> h3. Summary
> When a node gains or loses a mixin type after it already exists in the
> repository, the fulltext/property index is not updated. Nodes that gain a
> matching mixin are never indexed; nodes that lose a matching mixin are left
> as stale documents.
> h3. Root Cause
> {{FulltextIndexEditor.enter()}} derives {{indexingRule}} from the *after*
> node state. The {{propertiesChanged}} flag is only set by
> {{markPropertyChanged()}} when the changed property is explicitly listed in
> the rule's property definitions. {{jcr:mixinTypes}} is typically not listed,
> so:
> * *Mixin added:* rule found from after-state, but {{propertiesChanged}} stays
> false → {{leave()}} never calls {{addOrUpdate}} → node not indexed
> * *Mixin removed:* rule is null for after-state, {{isIndexable()}} is false →
> {{markPropertyChanged}} is a no-op → stale document remains in the index
> h3. Fix
> In {{enter()}}, compare the rule applicable to {{before}} vs {{after}} for
> existing nodes. If the rule was gained, force {{propertiesChanged = true}}.
> If the rule was lost, set a {{deletePreviousDocument}} flag and call
> {{deleteDocuments(path)}} in {{leave()}}.
> h3. Affected Files
> * {{oak-search}}: {{FulltextIndexEditor}} (core fix)
> * {{oak-search}}: {{PropertyIndexCommonTest}} (2 new integration tests, all
> backends)
> * {{oak-lucene}}: {{LuceneIndexEditor2Test}} (2 new unit tests verifying
> writer interactions)
> h3. Test Evidence
> Before fix: {{nodeGainsMixinTriggersIndexUpdate}},
> {{nodeLosesMixinTriggersDocumentDeletion}},
> {{nodeGainsMixinAppearsInMixinBasedIndex}} all fail.
> After fix: All pass. Full oak-lucene suite: 1242 tests, 0 failures.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)