OAK-12244: index nodes that gain a mixin rule, delete stale docs when…#2949
Open
thomasmueller wants to merge 2 commits into
Open
OAK-12244: index nodes that gain a mixin rule, delete stale docs when…#2949thomasmueller wants to merge 2 commits into
thomasmueller wants to merge 2 commits into
Conversation
… mixin rule is lost (#2938) When an existing node's applicable indexing rule changes at runtime (e.g. jcr:mixinTypes added or removed), FulltextIndexEditor did not update the index because propertiesChanged was never set — jcr:mixinTypes is not normally listed in a rule's property definitions. Track wasIndexable (rule matched before) alongside isIndexable() (rule matches after). In leave(), act on transitions: - !wasIndexable && isIndexable(): node gained a rule → addOrUpdate - wasIndexable && !isIndexable(): node lost a rule → deleteDocuments Tests added: - PropertyIndexCommonTest: two end-to-end integration tests (all backends) - LuceneIndexEditor2Test: two unit tests verifying writer.docs / writer.deletedPaths
|
) Root cause: when a node gains or loses a mixin type at runtime, FulltextIndexEditor did not update the index because propertiesChanged was never set — jcr:mixinTypes is not normally listed in a rule's property definitions. Fix: track wasIndexable (rule matched before) alongside isIndexable() (rule matches after). In leave(), act on the indexing-rule transition: - !wasIndexable && isIndexable(): node gained a rule → addOrUpdate - wasIndexable && !isIndexable(): node lost a rule → deleteDocument Split FulltextIndexWriter into two explicit operations: - deleteDocumentTree(path): node physically removed; cascade is correct - deleteDocument(path): node lost indexability at runtime; exact only The original deleteDocuments used a PrefixQuery that cascaded to all descendants; in the mixin-loss branch this was a bug — children carrying their own mixin types were incorrectly evicted from the index. Additional changes: - Snapshot FT_OAK_12244_DISABLE once per commit cycle in FulltextIndexEditorContext as typeChangeTrackingEnabled so enter() and leave() always agree - Skip getApplicableIndexingRule(before) on the hot path via hasNodeTypeChange guard when neither jcr:primaryType nor jcr:mixinTypes changed - Register FT_OAK_12244 toggle in ElasticIndexProviderService - Reuse CommitFailedException code 5 for the deleteDocument error path Tests: - PropertyIndexCommonTest: end-to-end integration tests (all backends) - LuceneIndexEditor2Test: unit tests verifying writer.docs / writer.deletedPaths - Verified: 1245 tests, 0 failures in oak-lucene
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



… mixin rule is lost (#2938)
TODO: right now the PR does a descendent-document delete if the primary type or mixin is changed / removed. This is incorrect and needs to be fixed.
When an existing node's applicable indexing rule changes at runtime (e.g. jcr:mixinTypes added or removed), FulltextIndexEditor did not update the index because propertiesChanged was never set — jcr:mixinTypes is not normally listed in a rule's property definitions.
Track wasIndexable (rule matched before) alongside isIndexable() (rule matches after). In leave(), act on transitions:
Tests added: