OAK-12089: Add Lucene 9 index provider (oak-search-lucene-ng) - #2817
OAK-12089: Add Lucene 9 index provider (oak-search-lucene-ng)#2817bhabegger wants to merge 3 commits into
Conversation
e4bc5ad to
dbccf97
Compare
28c304c to
66fb544
Compare
thomasmueller
left a comment
There was a problem hiding this comment.
Just some bikeshedding: I wonder if we should use the term "Lucene 9" at all.
| @@ -0,0 +1,26 @@ | |||
| # oak-search-luceneNg | |||
|
|
|||
| Lucene 9 index provider for Oak (`type="lucene9"`). | |||
There was a problem hiding this comment.
What about:
| Lucene 9 index provider for Oak (`type="lucene9"`). | |
| Lucene NG index provider for Oak (`type="lucene-ng"`). |
Hoping we can upgrade to Lucene 10 without having to change the type. I do assume the index storage version won't change, or that there is an option to add compatibility.
If not, and we do need to reindex for lucene 10, we can still add "lucene-ng-10" if that should be needed.
There was a problem hiding this comment.
So the idea is that the code should be less sensitive to Lucene upgrades. However, I wasn't really sure about having a fixed name and the in some future having to have a lucene-ng-ng ;) Here we could interpret it as lucene since 9 and still use that for lucene 10, 11 up to and imaginary lucene 12 that breaks compatibility again (which might never happen as likely the APIs are more stable now).
Personally, I fine with lucene-ng as I myself had doubts.
There was a problem hiding this comment.
Also the NG in the code for now is fine since we do have 2 versions, but at some point my expectation is that the legacy code be removed and the NG no longer be new generation and be refactored with proper non NG names. So in the code I'm fine, in the type however, this sticks more. That's mostly what bother me with ng in the type.
There was a problem hiding this comment.
@thomasmueller What about lucene2026 ? Less tied to 9 doesn't have explicit ng ?
There was a problem hiding this comment.
Let's vote here for this: https://github.com/orgs/oak-indexing/discussions/1289
f0a7199 to
de83bda
Compare
7cbee48 to
5b36b34
Compare
|
Introduces oak-search-luceneNg, a new Oak module providing a Lucene 9 based index engine under type=lucene9, with full parity to the legacy lucene implementation for property queries, fulltext, sorting, excerpts, and facets (insecure, statistical, and secure ACL modes). Key changes: - New oak-search-luceneNg module: index editor, query index, tracker, index node, storage, and OSGi wiring - Facet parity: LuceneNgSecure/StatisticalSortedSetDocValuesFacetCounts ported to Lucene 9 APIs with null-safe MatchingDocs.bits handling - LuceneNgFacetCommonTest extends FacetCommonTest for JCR-level coverage - AbstractIndexComparisonTest inlined into oak-search test-jar; oak-search-test module removed - getRootBuilder removed from ContextAwareCallback and IndexUpdate - leaf OSGi property removed from LuceneIndexProviderService - README documents feature parity vs legacy Lucene and Elastic Made-with: Cursor
5b36b34 to
c335365
Compare
amit-jain
left a comment
There was a problem hiding this comment.
I think there are some architectural gaps which we should address, some are even mentioned in the readme as well and could be addressed with these changes.
Mainly we should reuse the FulltextIndexEditor and FulltextIndexTracker from the oak-search module which the elastic module also reuses and extends.
|
|
||
| public IndexSearcherHolder(NodeState storageState, String indexName) throws IOException { | ||
| this.indexName = indexName; | ||
| this.directory = new OakDirectory(storageState.builder(), indexName, true); |
There was a problem hiding this comment.
NRT handling is an important part ans is also missing i think
There was a problem hiding this comment.
I heard a lot about NRT being mostly abused and I think we could have a first go without it. I would like to test an already big change. Let's make sure everything works without NRT and then add it back in a second step.
There was a problem hiding this comment.
I heard a lot about NRT being mostly abused
Ok I am not aware of the abuse, can you share more details.
Also, no problem in doing as a second step but I just highlighted things missing.
There was a problem hiding this comment.
Some users put nrt just because they can, not because they need it.
There was a problem hiding this comment.
Let's keep this like this for now. I would really like to test this first "core" implementation on indices where it already has sufficient features and then extend the features to cover the other cases.
Limitations are anyway documented here in the README
There was a problem hiding this comment.
Let's keep this like this for now. I would really like to test this first "core" implementation on indices where it already has sufficient features and then extend the features to cover the other cases.
This functionality was added afair as users complained adding a doc and not being able to search on it.
Some users put nrt just because they can, not because they need it.
And does it create a problem? But for users requiring it, not having this it creates a problem
Also, adding this with the extended common oak-search extension might have some quirks (new overloaded methods etc) which might be cleaner in a new impl as this.
BTW i am just looking at this from a parity pov and do not have a personal view on it. @thomasmueller can best suggest if we are ok not adding it initially.
There was a problem hiding this comment.
And does it create a problem? But for users requiring it, not having this it creates a problem
That's very general question that fits better around a coffee or a beer ;)
But understood that there are cases where this current version will not work. And it never has been the intent of this first PR to be feature complete, only to be a first step towards it.
There was a problem hiding this comment.
Also, adding this with the extended common oak-search extension might have some quirks (new overloaded methods etc) which might be cleaner in a new impl as this.
I'm not sure what you meant exactly by this. If it is to generalize and simplify the code, I'm all in. Just note that, this PR was voluntarily built in a way to keep running production code not using this feature completely untouched. (Notice only tests have been adjusted to validate feature iso-behavior).
|
Another important missing piece that is needed is the local fs index file support with the IndexCopier etc class which then get called with https://github.com/apache/jackrabbit-oak/blob/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/reader/DefaultIndexReaderFactory.java#L97 |
…eManager/FulltextIndexTracker Replaces the hand-rolled LuceneNgIndexNode/LuceneNgIndexTracker lifecycle/locking with the shared oak-search IndexNode/IndexNodeManager/FulltextIndexTracker framework, mirroring ElasticIndexNode/ElasticIndexNodeManager/ElasticIndexTracker. Fixes the documented IndexSearcherHolder.getFacetReaderState() vs close() race: releaseResources() (where the searcher is actually closed) now cannot run until every acquire()-held read lock has been released, because IndexNodeManager.close() holds its write lock across the whole closed=true flip. LuceneNgIndexNode now implements IndexNode directly (no more AcquiredNode inner class). LuceneNgIndexTracker.acquireIndexNode(String) returns LuceneNgIndexNode directly. New LuceneNgIndexNodeManager (luceneNg.internal) wraps one generation of a node per the Elastic pattern. Two deviations from a naive port, needed for correctness: - LuceneNgIndexTracker overrides isUpdateNeeded() to diff the whole subtree instead of relying on FulltextIndexTracker's default (:status/:index-definition), since this module's editor never writes either of those nodes -- Lucene segment files live directly under the index definition node itself. - LuceneNgIndexNode.release() cannot call the inherited protected IndexNodeManager.release() directly (it isn't an IndexNodeManager subclass); added a package-private LuceneNgIndexNodeManager.releaseNode() wrapper. Also updates callers to compile/behave correctly against the new API: - LuceneNgIndex.java, internal/LuceneNgCursor.java: AcquiredNode -> LuceneNgIndexNode. - LuceneNgIndexProviderService.java: FulltextIndexTracker.close() is package-private to oak-search and unreachable from here; deactivate() now drives tracker.update(EMPTY_NODE) instead, which closes every tracked IndexNodeManager through the same public API. - LuceneNgQueryIndexProvider.java (not in the original file list, but required to compile and to avoid a real regression): getQueryIndexes() now enumerates lucene9 indexes directly off the given NodeState rather than tracker.getIndexNodePaths(), since the shared tracker only caches paths already opened at least once and does not itself do full-repository discovery on update(). Adapts LuceneNgIndexTrackerTest/LuceneNgIndexNodeTest per the task brief, plus mechanical fixes (type renames, tracker.close() -> tracker.update(EMPTY_NODE)) in IntegrationTest, LuceneNgCursorBatchingTest and LuceneNgIndexTest so the module keeps compiling. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
7c648cd to
a82839a
Compare
Can you remind me what this is for ? Is this a must for this PR or can it be moved to later ? |
https://jackrabbit.apache.org/oak/docs/query/lucene.html#copyonread |
Ok, so this is in fact a performance optimization in the case the NodeStore is remote (many cases I agree). This doesn't block functional testing though (unless performance is so degraded that this becomes just not usable at all even restricted to testing). I would accept this for now, and leave open to solve the performance issue in maybe some way different than how it was managed in the legacy. Ok, with you to differ ? |
8c5cc0b to
402d45c
Compare
…eak, and adopt shared FulltextIndex/FulltextIndexPlanner for LuceneNgIndex query planning
402d45c to
605a3a6
Compare
Summary
Introduces
oak-search-lucene-ng, a new Oak module that provides a Lucene 9 based index engine. Indexes opt in explicitly viatype=lucene9; all existing indexes are unaffected.oak-search-luceneNgmodule: index editor, query index, tracker, index node, storage (Oak JCR node-based directory), and OSGi wiringluceneengine: property restrictions, path/type filters, fulltext, sorting, and excerptsMatchingDocs.bitshandlingLuceneNgFacetCommonTestextends the sharedFacetCommonTestsuite for end-to-end JCR-level facet coverageAbstractIndexComparisonTestinlined intooak-searchtest-jar;oak-search-testmodule removed