-
Notifications
You must be signed in to change notification settings - Fork 424
OAK-12089: Add Lucene 9 index provider (oak-search-luceneNg) #2817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bhabegger
wants to merge
5
commits into
apache:OAK-12089
Choose a base branch
from
bhabegger:oak-12089-lucene9-core
base: OAK-12089
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
66fb544
feat: add Lucene 9 index provider (oak-search-luceneNg)
bhabegger 1be8d86
feat: support localname() queries via NODE_NAME field indexing
bhabegger 2652c53
docs: clarify index augmentors and composite node store entries in RE…
bhabegger 144b835
refactor: rename module directory and artifactId to oak-search-lucene-ng
bhabegger f0a7199
test: remove LuceneNgFacetTest — all scenarios covered by LuceneNgFac…
bhabegger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
...c/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexComparisonTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.jackrabbit.oak.plugins.index.lucene; | ||
|
|
||
| import org.apache.jackrabbit.JcrConstants; | ||
| import org.apache.jackrabbit.oak.InitialContent; | ||
| import org.apache.jackrabbit.oak.Oak; | ||
| import org.apache.jackrabbit.oak.api.ContentRepository; | ||
| import org.apache.jackrabbit.oak.api.Tree; | ||
| import org.apache.jackrabbit.oak.api.Type; | ||
| import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants; | ||
| import org.apache.jackrabbit.oak.plugins.index.search.test.AbstractIndexComparisonTest; | ||
| import org.apache.jackrabbit.oak.spi.commit.Observer; | ||
| import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider; | ||
| import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NODE_TYPE; | ||
| import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_PROPERTY_NAME; | ||
| import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.TYPE_PROPERTY_NAME; | ||
| import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.INCLUDE_PROPERTY_NAMES; | ||
| import static org.apache.jackrabbit.oak.plugins.memory.PropertyStates.createProperty; | ||
|
|
||
| /** | ||
| * Runs the shared {@link AbstractIndexComparisonTest} scenarios against the legacy Lucene backend. | ||
| */ | ||
| public class LuceneIndexComparisonTest extends AbstractIndexComparisonTest { | ||
|
|
||
| @Override | ||
| protected ContentRepository createRepository() { | ||
| LuceneIndexProvider provider = new LuceneIndexProvider(); | ||
| return new Oak() | ||
| .with(new InitialContent()) | ||
| .with(new OpenSecurityProvider()) | ||
| .with((QueryIndexProvider) provider) | ||
| .with((Observer) provider) | ||
| .with(new LuceneIndexEditorProvider()) | ||
| .createContentRepository(); | ||
| } | ||
|
|
||
| @Override | ||
| protected void createTestIndexNode() throws Exception { | ||
| setTraversalEnabled(false); | ||
| } | ||
|
|
||
| @Override | ||
| protected void createSearchIndex() throws Exception { | ||
| Tree def = root.getTree("/oak:index").addChild("luceneTestIndex"); | ||
| def.setProperty(JcrConstants.JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE, Type.NAME); | ||
| def.setProperty(TYPE_PROPERTY_NAME, LuceneIndexConstants.TYPE_LUCENE); | ||
| def.setProperty(REINDEX_PROPERTY_NAME, true); | ||
| def.setProperty(FulltextIndexConstants.FULL_TEXT_ENABLED, false); | ||
| def.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, | ||
| List.of("title", "description", "age", "price", "status", "category"), Type.STRINGS)); | ||
| root.commit(); | ||
| } | ||
| } |
66 changes: 66 additions & 0 deletions
66
.../src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexMinimalTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| package org.apache.jackrabbit.oak.plugins.index.lucene; | ||
|
|
||
| import org.apache.jackrabbit.oak.InitialContent; | ||
| import org.apache.jackrabbit.oak.Oak; | ||
| import org.apache.jackrabbit.oak.api.ContentRepository; | ||
| import org.apache.jackrabbit.oak.api.Tree; | ||
| import org.apache.jackrabbit.oak.api.Type; | ||
| import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants; | ||
| import org.apache.jackrabbit.oak.query.AbstractQueryTest; | ||
| import org.apache.jackrabbit.oak.spi.commit.Observer; | ||
| import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider; | ||
| import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider; | ||
| import org.junit.Test; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.*; | ||
| import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.INCLUDE_PROPERTY_NAMES; | ||
| import static org.apache.jackrabbit.oak.plugins.memory.PropertyStates.createProperty; | ||
|
|
||
| public class LuceneIndexMinimalTest extends AbstractQueryTest { | ||
| @Override protected void createTestIndexNode() throws Exception { setTraversalEnabled(false); } | ||
|
|
||
| @Override | ||
| protected ContentRepository createRepository() { | ||
| LuceneIndexProvider provider = new LuceneIndexProvider(); | ||
| return new Oak().with(new InitialContent()).with(new OpenSecurityProvider()) | ||
| .with((QueryIndexProvider) provider).with((Observer) provider) | ||
| .with(new LuceneIndexEditorProvider()).createContentRepository(); | ||
| } | ||
|
|
||
| @Test | ||
| public void singleCommit() throws Exception { | ||
| // Index + content in ONE commit | ||
| Tree def = root.getTree("/oak:index").addChild("testIdx"); | ||
| def.setProperty("jcr:primaryType", INDEX_DEFINITIONS_NODE_TYPE, Type.NAME); | ||
| def.setProperty(TYPE_PROPERTY_NAME, LuceneIndexConstants.TYPE_LUCENE); | ||
| def.setProperty(REINDEX_PROPERTY_NAME, true); | ||
| def.setProperty(FulltextIndexConstants.FULL_TEXT_ENABLED, false); | ||
| def.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, List.of("title"), Type.STRINGS)); | ||
|
|
||
| Tree page = root.getTree("/").addChild("content").addChild("page1"); | ||
| page.setProperty("title", "Lucene Integration"); | ||
| root.commit(); | ||
|
|
||
| assertQuery("//element(*, nt:base)[@title = 'Lucene Integration']", "xpath", List.of("/content/page1")); | ||
| } | ||
|
|
||
| @Test | ||
| public void twoCommits() throws Exception { | ||
| // Index in first commit, content in second | ||
| Tree def = root.getTree("/oak:index").addChild("testIdx"); | ||
| def.setProperty("jcr:primaryType", INDEX_DEFINITIONS_NODE_TYPE, Type.NAME); | ||
| def.setProperty(TYPE_PROPERTY_NAME, LuceneIndexConstants.TYPE_LUCENE); | ||
| def.setProperty(REINDEX_PROPERTY_NAME, true); | ||
| def.setProperty(FulltextIndexConstants.FULL_TEXT_ENABLED, false); | ||
| def.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, List.of("title"), Type.STRINGS)); | ||
| root.commit(); | ||
|
|
||
| Tree page = root.getTree("/").addChild("content").addChild("page1"); | ||
| page.setProperty("title", "Lucene Integration"); | ||
| root.commit(); | ||
|
|
||
| assertQuery("//element(*, nt:base)[@title = 'Lucene Integration']", "xpath", List.of("/content/page1")); | ||
| } | ||
| } |
54 changes: 54 additions & 0 deletions
54
...rc/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneNodeNameCommonTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.jackrabbit.oak.plugins.index.lucene; | ||
|
|
||
| import org.apache.jackrabbit.oak.Oak; | ||
| import org.apache.jackrabbit.oak.jcr.Jcr; | ||
| import org.apache.jackrabbit.oak.plugins.index.LuceneIndexOptions; | ||
| import org.apache.jackrabbit.oak.plugins.index.NodeNameCommonTest; | ||
| import org.junit.After; | ||
| import org.junit.Rule; | ||
| import org.junit.rules.TemporaryFolder; | ||
|
|
||
| import javax.jcr.Repository; | ||
| import java.io.File; | ||
| import java.util.concurrent.ExecutorService; | ||
| import java.util.concurrent.Executors; | ||
|
|
||
| /** | ||
| * Runs {@link NodeNameCommonTest} against the legacy Lucene index. | ||
| */ | ||
| public class LuceneNodeNameCommonTest extends NodeNameCommonTest { | ||
|
|
||
| private ExecutorService executorService = Executors.newFixedThreadPool(2); | ||
|
|
||
| @Rule | ||
| public TemporaryFolder temporaryFolder = new TemporaryFolder(new File("target")); | ||
|
|
||
| @Override | ||
| protected Repository createJcrRepository() { | ||
| indexOptions = new LuceneIndexOptions(); | ||
| repositoryOptionsUtil = new LuceneTestRepositoryBuilder(executorService, temporaryFolder).build(); | ||
| Oak oak = repositoryOptionsUtil.getOak(); | ||
| return new Jcr(oak).createRepository(); | ||
| } | ||
|
|
||
| @After | ||
| public void shutdownExecutor() { | ||
| executorService.shutdown(); | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # oak-search-lucene-ng | ||
|
|
||
| Lucene 9 index provider for Oak (`type="lucene9"`). | ||
|
|
||
| ## Feature parity | ||
|
|
||
| | Feature | Legacy Lucene | Elastic | LuceneNg | | ||
| |---|---|---|---| | ||
| | Property restrictions, path/type filters | ✓ | ✓ | ✓ | | ||
| | Fulltext search | ✓ | ✓ | ✓ | | ||
| | Facets (insecure / statistical / secure) | ✓ | ✓ | ✓ | | ||
| | Excerpts | ✓ | ✓ | ✓ | | ||
| | Ordering / sorting | ✓ | ✓ | ✓ | | ||
| | Suggestions | ✓ | ✓ | ✗ | | ||
| | Spellcheck | ✓ | ✓ | ✗ | | ||
| | Similarity / More Like This | ✓ | ✓ (+ KNN) | ✗ | | ||
| | Native queries | ✓ | ✓ | ✗ | | ||
| | Index statistics / JMX | ✓ | ✓ | ✗ | | ||
| | Index augmentors [^1] | ✓ | ✗ | ✗ | | ||
| | NRT / hybrid indexing | ✓ | ✗ | ✗ | | ||
| | Index copier (CopyOnRead/Write) | ✓ | ✗ | ✗ | | ||
| | Composite node store queries [^2] | ✓ | ✗ | ✗ | | ||
| | Inference / vector search | ✗ | ✓ | ✗ | | ||
|
|
||
| [^1]: Index augmentors are OSGi services (`IndexFieldProvider`, `FulltextQueryTermsProvider`) that let third-party code inject additional fields into indexed documents or expand fulltext queries, without modifying the index definition. | ||
| [^2]: When the repository is backed by a composite node store (e.g. a read-only `/apps`+`/libs` mount combined with a writeable store), the Lucene index runs one query per mount and merges the results. This feature is not required for a single-store deployment. | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about:
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thomasmueller What about lucene2026 ? Less tied to 9 doesn't have explicit ng ?