This is an automated email from the ASF dual-hosted git repository.
fortino pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new 6b9b154d63 OAK-11824 lucene analyzer factory should be able to load
indirect filters (#2413)
6b9b154d63 is described below
commit 6b9b154d63efbfc4fed869eb22f54b711c6dc60e
Author: Fabrizio Fortino <[email protected]>
AuthorDate: Thu Jul 31 18:04:17 2025 +0200
OAK-11824 lucene analyzer factory should be able to load indirect filters
(#2413)
---
.../index/lucene/NodeStateAnalyzerFactory.java | 7 ++++++-
.../index/elastic/ElasticFullTextAnalyzerTest.java | 19 -----------------
.../plugins/index/FullTextAnalyzerCommonTest.java | 24 ++++++++++++++++++++++
3 files changed, 30 insertions(+), 20 deletions(-)
diff --git
a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactory.java
b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactory.java
index 8623d22d43..ee08fc1718 100644
---
a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactory.java
+++
b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactory.java
@@ -284,7 +284,12 @@ final class NodeStateAnalyzerFactory {
@Override
public <T> T newInstance(String cname, Class<T> expectedType) {
- throw new UnsupportedOperationException();
+ try {
+ Class<? extends T> clazz = findClass(cname, expectedType);
+ return clazz.getDeclaredConstructor().newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to create instance of " +
cname, e);
+ }
}
}
}
diff --git
a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFullTextAnalyzerTest.java
b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFullTextAnalyzerTest.java
index 179d48892b..1b56e803f8 100644
---
a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFullTextAnalyzerTest.java
+++
b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFullTextAnalyzerTest.java
@@ -234,25 +234,6 @@ public class ElasticFullTextAnalyzerTest extends
FullTextAnalyzerCommonTest {
});
}
- @Test
- public void fulltextSearchWithSnowball() throws Exception {
- setup(List.of("foo"), idx -> {
- Tree anl =
idx.addChild(FulltextIndexConstants.ANALYZERS).addChild(FulltextIndexConstants.ANL_DEFAULT);
-
anl.addChild(FulltextIndexConstants.ANL_TOKENIZER).setProperty(FulltextIndexConstants.ANL_NAME,
"Standard");
-
- Tree filters = anl.addChild(FulltextIndexConstants.ANL_FILTERS);
- Tree snowball = addFilter(filters, "SnowballPorter");
- snowball.setProperty("language", "Italian");
- });
-
- Tree content = root.getTree("/").addChild("content");
- content.addChild("bar").setProperty("foo", "mangio la mela");
- content.addChild("baz").setProperty("foo", "altro testo");
- root.commit();
-
- assertEventually(() -> assertQuery("select * from [nt:base] where
CONTAINS(*, 'mangiare')", List.of("/content/bar")));
- }
-
@Test
@Ignore("not supported in elasticsearch since hunspell resources need to
be available on the server")
@Override
diff --git
a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/FullTextAnalyzerCommonTest.java
b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/FullTextAnalyzerCommonTest.java
index 3821a084b0..77db9cb669 100644
---
a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/FullTextAnalyzerCommonTest.java
+++
b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/FullTextAnalyzerCommonTest.java
@@ -1261,6 +1261,30 @@ public abstract class FullTextAnalyzerCommonTest extends
AbstractQueryTest {
});
}
+ @Test
+ public void fulltextSearchWithSnowball() throws Exception {
+ setup(List.of("foo"), idx -> {
+ Tree anl =
idx.addChild(FulltextIndexConstants.ANALYZERS).addChild(FulltextIndexConstants.ANL_DEFAULT);
+
anl.addChild(FulltextIndexConstants.ANL_TOKENIZER).setProperty(FulltextIndexConstants.ANL_NAME,
"Standard");
+
+ Tree filters = anl.addChild(FulltextIndexConstants.ANL_FILTERS);
+ Tree snowball = addFilter(filters, "SnowballPorter");
+ snowball.setProperty("language", "Italian");
+ });
+
+ Tree content = root.getTree("/").addChild("content");
+ content.addChild("bar").setProperty("foo", "mangio la mela");
+ content.addChild("baz").setProperty("foo", "altro testo");
+ content.addChild("bat").setProperty("foo", "nuovo testo");
+ root.commit();
+
+ assertEventually(() -> {
+ assertQuery("select * from [nt:base] where CONTAINS(*,
'mangiare')", List.of("/content/bar"));
+ assertQuery("select * from [nt:base] where CONTAINS(*,
'nuova testa')", List.of("/content/bat"));
+ }
+ );
+ }
+
protected Tree addFilter(Tree analyzer, String filterName) {
Tree filter = analyzer.addChild(filterName);
// mimics nodes api