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 31354ef803..5935f45953 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 @@ -93,6 +93,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.io.CountingInputStream; + import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.jackrabbit.JcrConstants; @@ -119,6 +120,7 @@ import org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider; import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider; import org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob; import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore; +import org.apache.jackrabbit.oak.plugins.memory.MultiStringPropertyState; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; import org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider; import org.apache.jackrabbit.oak.InitialContent; @@ -2391,6 +2393,35 @@ public class LucenePropertyIndexTest extends AbstractQueryTest { } @Test + public void restrictionPropagation() throws Exception{ + Tree idx = createIndex("test2", of("propa", "propb")); + /*Tree props = TestUtil.newRulePropTree(idx, "nt:base"); + Tree prop1 = props.addChild(TestUtil.unique("prop")); + prop1.setProperty(LuceneIndexConstants.PROP_NAME, "jcr:content/metadata/comment"); + prop1.setProperty(LuceneIndexConstants.PROP_ANALYZED, true);*/ + root.commit(); + + Tree testFoo = root.getTree("/").addChild("testFoo"); + testFoo.setProperty("propa", true); + testFoo.setProperty(MultiStringPropertyState.stringProperty("propb", Collections.singleton("foo"))); + Tree testBar = root.getTree("/").addChild("testBar"); + testBar.setProperty("propa", false); + testBar.setProperty(MultiStringPropertyState.stringProperty("propb", Collections.singleton("bar"))); + + root.commit(); + + String firstStatementQuery = "select * from [nt:base] where ([propa] = 'true' and [propb] in('foo','bar'))"; + String secondStatementQuery = "select * from [nt:base] where ([propa] = 'false' and not([propb] in('foo','bar')))"; + String bothStatementsQuery = "select * from [nt:base] where ([propa] = 'true' and [propb] in('foo','bar')) or ([propa] = 'false' and not([propb] in('foo','bar')))"; + + for (String propabQuery : new String[] {firstStatementQuery, secondStatementQuery, bothStatementsQuery }) { + String explanation = explain(propabQuery); + assertThat("For query " + propabQuery, explanation, containsString("propa")); + assertThat("For query " + propabQuery, explanation, containsString("propb")); + } + } + + @Test public void longRepExcerpt() throws Exception { Tree luceneIndex = createFullTextIndex(root.getTree("/"), "lucene");