This is an automated email from the ASF dual-hosted git repository. ngupta pushed a commit to branch 1.22 in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/1.22 by this push: new 3c6196a9a1 OAK-9481: avoid range queries on like conditions (#308) 3c6196a9a1 is described below commit 3c6196a9a1ff90564d87b8692568318c54042c37 Author: Fabrizio Fortino <fabrizio.fort...@gmail.com> AuthorDate: Fri Jul 2 14:28:27 2021 +0200 OAK-9481: avoid range queries on like conditions (#308) * add unit test around like queries on multi values props * fix to avoid range queries on like conditions --- .../jackrabbit/oak/query/ast/ComparisonImpl.java | 10 ---------- .../plugins/index/lucene/LucenePropertyIndexTest.java | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ComparisonImpl.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ComparisonImpl.java index c8c0472e81..59568dc895 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ComparisonImpl.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ComparisonImpl.java @@ -166,17 +166,7 @@ public class ComparisonImpl extends ConstraintImpl { // but v may contain escaped wildcards, so we can't use it PropertyValue pv = PropertyValues.newString(lowerBound); operand1.restrict(f, Operator.EQUAL, pv); - } else if (operand1.supportsRangeConditions()) { - if (lowerBound != null) { - PropertyValue pv = PropertyValues.newString(lowerBound); - operand1.restrict(f, Operator.GREATER_OR_EQUAL, pv); - } - if (upperBound != null) { - PropertyValue pv = PropertyValues.newString(upperBound); - operand1.restrict(f, Operator.LESS_OR_EQUAL, pv); - } } else { - // path conditions operand1.restrict(f, operator, v); } } else { diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java index fe5cb28212..9ef5f211db 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java @@ -658,6 +658,24 @@ public class LucenePropertyIndexTest extends AbstractQueryTest { luceneQuery); } + @Test + public void multiValuesLike() throws Exception{ + Tree idx = createIndex("test1", of("references")); + root.commit(); + + Tree test = root.getTree("/").addChild("test"); + test.addChild("a").setProperty("references", of("/some/content/AAA", "/some/content/BBB"), Type.STRINGS); + test.addChild("b").setProperty("references", of("/some/content/AAA", "/some/content/CCC"), Type.STRINGS); + root.commit(); + + String q = "SELECT * FROM [nt:unstructured] as content WHERE references LIKE '/some/content/efjoiefjowfgj/%'"; + String explain = explain(q); + String luceneQuery = explain.substring(0, explain.indexOf('\n')); + assertEquals("[nt:unstructured] as [content] /* lucene:test1(/oak:index/test1) " + + "references:/some/content/efjoiefjowfgj/*", + luceneQuery); + } + @Test public void redundantNotNullCheck() throws Exception{ Tree idx = createIndex("test1", of("tags"));