Author: chetanm
Date: Tue May 19 05:31:12 2015
New Revision: 1680171

URL: http://svn.apache.org/r1680171
Log:
OAK-2599 - Allow excluding certain paths from getting indexed for particular 
index

Merging 1677611

Added:
    
jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/PathFilter.java
      - copied unchanged from r1677611, 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/PathFilter.java
    
jackrabbit/oak/branches/1.2/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/PathFilterTest.java
      - copied unchanged from r1677611, 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/PathFilterTest.java
Modified:
    jackrabbit/oak/branches/1.2/   (props changed)
    
jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexConstants.java
    
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java
    
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlanner.java
    
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditor.java
    
jackrabbit/oak/branches/1.2/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlannerTest.java
    
jackrabbit/oak/branches/1.2/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java

Propchange: jackrabbit/oak/branches/1.2/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue May 19 05:31:12 2015
@@ -1,3 +1,3 @@
 /jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1672350,1672468,1672537,1672603,1672642,1672644,1672834-1672835,1673351,1673410,1673414,1673436,1673644,1673662-1673664,1673669,1673695,1674046,1674065,1674075,1674107,1674228,1674880,1675055,1675332,1675354,1675357,1675593,1676198,1676237,1676407,1676458,1676539,1676670,1676725,1677579,1677581,1677609,1677939,1678173,1678758,1678938,1679165,1679191,1679235
+/jackrabbit/oak/trunk:1672350,1672468,1672537,1672603,1672642,1672644,1672834-1672835,1673351,1673410,1673414,1673436,1673644,1673662-1673664,1673669,1673695,1674046,1674065,1674075,1674107,1674228,1674880,1675055,1675332,1675354,1675357,1675593,1676198,1676237,1676407,1676458,1676539,1676670,1676725,1677579,1677581,1677609,1677611,1677939,1678173,1678758,1678938,1679165,1679191,1679235
 /jackrabbit/trunk:1345480

Modified: 
jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexConstants.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexConstants.java?rev=1680171&r1=1680170&r2=1680171&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexConstants.java
 (original)
+++ 
jackrabbit/oak/branches/1.2/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexConstants.java
 Tue May 19 05:31:12 2015
@@ -61,4 +61,10 @@ public interface IndexConstants {
     String DECLARING_NODE_TYPES = "declaringNodeTypes";
 
     String INDEX_CONTENT_NODE_NAME = ":index";
+
+    /**
+     * MVP to define the paths for which the index can be used to perform
+     * queries. Defaults to ['/'].
+     */
+    String QUERY_PATHS = "queryPaths";
 }

Modified: 
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java?rev=1680171&r1=1680170&r2=1680171&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java
 (original)
+++ 
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java
 Tue May 19 05:31:12 2015
@@ -47,6 +47,8 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
+import org.apache.jackrabbit.oak.plugins.index.IndexConstants;
+import org.apache.jackrabbit.oak.plugins.index.PathFilter;
 import org.apache.jackrabbit.oak.plugins.index.lucene.util.ConfigUtil;
 import org.apache.jackrabbit.oak.plugins.index.lucene.util.TokenizerChain;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
@@ -56,6 +58,7 @@ import org.apache.jackrabbit.oak.spi.que
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.ReadOnlyBuilder;
 import org.apache.jackrabbit.oak.util.TreeUtil;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.miscellaneous.LimitTokenCountAnalyzer;
@@ -197,6 +200,11 @@ class IndexDefinition implements Aggrega
 
     private final int suggesterUpdateFrequencyMinutes;
 
+    private final PathFilter pathFilter;
+
+    @Nullable
+    private final String[] queryPaths;
+
     private final boolean saveDirListing;
 
     public IndexDefinition(NodeState root, NodeState defn) {
@@ -259,6 +267,8 @@ class IndexDefinition implements Aggrega
         this.maxExtractLength = determineMaxExtractLength();
         this.suggesterUpdateFrequencyMinutes = getOptionalValue(defn, 
LuceneIndexConstants.SUGGEST_UPDATE_FREQUENCY_MINUTES, 60);
         this.scorerProviderName = getOptionalValue(defn, 
LuceneIndexConstants.PROP_SCORER_PROVIDER, null);
+        this.pathFilter = PathFilter.from(new ReadOnlyBuilder(defn));
+        this.queryPaths = getQueryPaths(defn);
         this.saveDirListing = getOptionalValue(defn, 
LuceneIndexConstants.SAVE_DIR_LISTING, false);
     }
 
@@ -368,6 +378,15 @@ class IndexDefinition implements Aggrega
         return saveDirListing;
     }
 
+    public PathFilter getPathFilter() {
+        return pathFilter;
+    }
+
+    @Nullable
+    public String[] getQueryPaths() {
+        return queryPaths;
+    }
+
     @Override
     public String toString() {
         return "Lucene Index : " + indexName;
@@ -1310,6 +1329,14 @@ class IndexDefinition implements Aggrega
         return result;
     }
 
+    private String[] getQueryPaths(NodeState defn) {
+        PropertyState ps = defn.getProperty(IndexConstants.QUERY_PATHS);
+        if (ps != null){
+            return Iterables.toArray(ps.getValue(Type.STRINGS), String.class);
+        }
+        return null;
+    }
+
     private static IndexFormatVersion versionFrom(PropertyState ps){
         return 
IndexFormatVersion.getVersion(Ints.checkedCast(ps.getValue(Type.LONG)));
     }

Modified: 
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlanner.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlanner.java?rev=1680171&r1=1680170&r2=1680171&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlanner.java
 (original)
+++ 
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlanner.java
 Tue May 19 05:31:12 2015
@@ -124,6 +124,12 @@ class IndexPlanner {
             return null;
         }
 
+        if (!checkForQueryPaths()) {
+            log.trace("Opting out due mismatch between path restriction {} and 
query paths {}",
+                    filter.getPath(), definition.getQueryPaths());
+            return null;
+        }
+
         result = new PlanResult(indexPath, definition, indexingRule);
 
         if (definition.hasFunctionDefined()
@@ -197,6 +203,29 @@ class IndexPlanner {
         return null;
     }
 
+    /**
+     * Check if there is a mismatch between QueryPaths associated with index
+     * and path restriction specified in query
+
+     * @return true if QueryPaths and path restrictions do not have any 
conflict
+     */
+    private boolean checkForQueryPaths() {
+        String[] queryPaths = definition.getQueryPaths();
+        if (queryPaths == null){
+            //No explicit value specified. Assume '/' which results in true
+            return true;
+        }
+
+        String pathRestriction = filter.getPath();
+        for (String queryPath : queryPaths){
+            if (queryPath.equals(pathRestriction) || 
PathUtils.isAncestor(queryPath, pathRestriction)){
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     private static boolean canSortByProperty(List<OrderEntry> sortOrder) {
         if (sortOrder.isEmpty()) {
             return false;

Modified: 
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditor.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditor.java?rev=1680171&r1=1680170&r2=1680171&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditor.java
 (original)
+++ 
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditor.java
 Tue May 19 05:31:12 2015
@@ -48,6 +48,7 @@ import org.apache.jackrabbit.oak.api.Typ
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.plugins.index.IndexEditor;
 import org.apache.jackrabbit.oak.plugins.index.IndexUpdateCallback;
+import org.apache.jackrabbit.oak.plugins.index.PathFilter;
 import org.apache.jackrabbit.oak.plugins.index.lucene.Aggregate.Matcher;
 import org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState;
 import org.apache.jackrabbit.oak.plugins.tree.TreeFactory;
@@ -112,6 +113,8 @@ public class LuceneIndexEditor implement
 
     private final MatcherState matcherState;
 
+    private final PathFilter.Result pathFilterResult;
+
     LuceneIndexEditor(NodeState root, NodeBuilder definition,
         IndexUpdateCallback updateCallback) throws CommitFailedException {
         this.parent = null;
@@ -122,10 +125,12 @@ public class LuceneIndexEditor implement
         this.root = root;
         this.isDeleted = false;
         this.matcherState = MatcherState.NONE;
+        this.pathFilterResult = 
context.getDefinition().getPathFilter().doFiler(getPath());
     }
 
     private LuceneIndexEditor(LuceneIndexEditor parent, String name,
                               MatcherState matcherState,
+                              PathFilter.Result pathFilterResult,
             boolean isDeleted) {
         this.parent = parent;
         this.name = name;
@@ -134,6 +139,7 @@ public class LuceneIndexEditor implement
         this.root = parent.root;
         this.isDeleted = isDeleted;
         this.matcherState = matcherState;
+        this.pathFilterResult = pathFilterResult;
     }
 
     public String getPath() {
@@ -159,12 +165,17 @@ public class LuceneIndexEditor implement
             beforeTree = parent.beforeTree.getChild(name);
         }
 
-        //For traversal in deleted sub tree before state has to be used
-        Tree current = afterTree.exists() ? afterTree : beforeTree;
-        indexingRule = getDefinition().getApplicableIndexingRule(current);
+        //Only check for indexing if the result is include.
+        //In case like TRAVERSE nothing needs to be indexed for those
+        //path
+        if (pathFilterResult == PathFilter.Result.INCLUDE) {
+            //For traversal in deleted sub tree before state has to be used
+            Tree current = afterTree.exists() ? afterTree : beforeTree;
+            indexingRule = getDefinition().getApplicableIndexingRule(current);
 
-        if (indexingRule != null) {
-            currentMatchers = indexingRule.getAggregate().createMatchers(this);
+            if (indexingRule != null) {
+                currentMatchers = 
indexingRule.getAggregate().createMatchers(this);
+            }
         }
     }
 
@@ -218,18 +229,30 @@ public class LuceneIndexEditor implement
 
     @Override
     public Editor childNodeAdded(String name, NodeState after) {
-        return new LuceneIndexEditor(this, name, getMatcherState(name, after), 
false);
+        PathFilter.Result filterResult = getPathFilterResult(name);
+        if (filterResult != PathFilter.Result.EXCLUDE) {
+            return new LuceneIndexEditor(this, name, getMatcherState(name, 
after), filterResult, false);
+        }
+        return null;
     }
 
     @Override
     public Editor childNodeChanged(
             String name, NodeState before, NodeState after) {
-        return new LuceneIndexEditor(this, name, getMatcherState(name, after), 
false);
+        PathFilter.Result filterResult = getPathFilterResult(name);
+        if (filterResult != PathFilter.Result.EXCLUDE) {
+            return new LuceneIndexEditor(this, name, getMatcherState(name, 
after), filterResult, false);
+        }
+        return null;
     }
 
     @Override
     public Editor childNodeDeleted(String name, NodeState before)
             throws CommitFailedException {
+        PathFilter.Result filterResult = getPathFilterResult(name);
+        if (filterResult == PathFilter.Result.EXCLUDE) {
+            return null;
+        }
 
         if (!isDeleted) {
             // tree deletion is handled on the parent node
@@ -249,7 +272,7 @@ public class LuceneIndexEditor implement
 
         MatcherState ms = getMatcherState(name, before);
         if (!ms.isEmpty()){
-            return new LuceneIndexEditor(this, name, ms, true);
+            return new LuceneIndexEditor(this, name, ms, filterResult, true);
         }
         return null; // no need to recurse down the removed subtree
     }
@@ -767,6 +790,10 @@ public class LuceneIndexEditor implement
         return indexingRule != null;
     }
 
+    private PathFilter.Result getPathFilterResult(String childNodeName) {
+        return 
context.getDefinition().getPathFilter().doFiler(concat(getPath(), 
childNodeName));
+    }
+
     private boolean isSupportedMediaType(String type) {
         return context.isSupportedMediaType(type);
     }

Modified: 
jackrabbit/oak/branches/1.2/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlannerTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlannerTest.java?rev=1680171&r1=1680170&r2=1680171&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.2/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlannerTest.java
 (original)
+++ 
jackrabbit/oak/branches/1.2/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlannerTest.java
 Tue May 19 05:31:12 2015
@@ -54,6 +54,7 @@ import static org.apache.jackrabbit.JcrC
 import static org.apache.jackrabbit.oak.api.Type.NAMES;
 import static org.apache.jackrabbit.oak.api.Type.STRINGS;
 import static 
org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME;
+import static 
org.apache.jackrabbit.oak.plugins.index.PathFilter.PROP_INCLUDED_PATHS;
 import static 
org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.INDEX_DATA_CHILD_NAME;
 import static 
org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.INDEX_RULES;
 import static 
org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.ORDERED_PROP_NAMES;
@@ -336,7 +337,7 @@ public class IndexPlannerTest {
         filter.restrictProperty("foo", Operator.EQUAL, null);
         IndexPlanner planner = new IndexPlanner(node, "/foo", filter, 
Collections.<OrderEntry>emptyList());
         QueryIndex.IndexPlan plan = planner.getPlan();
-        assertNull("For null checks no plan should be returned",plan);
+        assertNull("For null checks no plan should be returned", plan);
     }
 
     @Test
@@ -363,6 +364,44 @@ public class IndexPlannerTest {
         assertNotNull(pr.getPropDefn(filter.getPropertyRestriction("foo")));
     }
 
+    @Test
+    public void noPathRestHasQueryPath() throws Exception{
+        NodeBuilder defn = newLucenePropertyIndexDefinition(builder, "test", 
of("foo"), "async");
+        defn.setProperty(createProperty(IndexConstants.QUERY_PATHS, 
of("/test/a"), Type.STRINGS));
+        IndexNode node = createIndexNode(new IndexDefinition(root, 
defn.getNodeState()));
+
+        FilterImpl filter = createFilter("nt:base");
+        filter.restrictProperty("foo", Operator.EQUAL, 
PropertyValues.newString("bar"));
+        filter.restrictPath("/test2", Filter.PathRestriction.ALL_CHILDREN);
+        IndexPlanner planner = new IndexPlanner(node, "/foo", filter, 
Collections.<OrderEntry>emptyList());
+        assertNull(planner.getPlan());
+    }
+
+    @Test
+    public void hasPathRestHasMatchingQueryPaths() throws Exception{
+        NodeBuilder defn = newLucenePropertyIndexDefinition(builder, "test", 
of("foo"), "async");
+        defn.setProperty(createProperty(IndexConstants.QUERY_PATHS, 
of("/test/a", "/test/b"), Type.STRINGS));
+        IndexNode node = createIndexNode(new IndexDefinition(root, 
defn.getNodeState()));
+
+        FilterImpl filter = createFilter("nt:base");
+        filter.restrictPath("/test/a", Filter.PathRestriction.ALL_CHILDREN);
+        filter.restrictProperty("foo", Operator.EQUAL, 
PropertyValues.newString("bar"));
+        IndexPlanner planner = new IndexPlanner(node, "/foo", filter, 
Collections.<OrderEntry>emptyList());
+        assertNotNull(planner.getPlan());
+    }
+
+    @Test
+    public void hasPathRestHasNoExplicitQueryPaths() throws Exception{
+        NodeBuilder defn = newLucenePropertyIndexDefinition(builder, "test", 
of("foo"), "async");
+        IndexNode node = createIndexNode(new IndexDefinition(root, 
defn.getNodeState()));
+
+        FilterImpl filter = createFilter("nt:base");
+        filter.restrictPath("/test2", Filter.PathRestriction.ALL_CHILDREN);
+        filter.restrictProperty("foo", Operator.EQUAL, 
PropertyValues.newString("bar"));
+        IndexPlanner planner = new IndexPlanner(node, "/foo", filter, 
Collections.<OrderEntry>emptyList());
+        assertNotNull(planner.getPlan());
+    }
+
     private IndexNode createIndexNode(IndexDefinition defn, long numOfDocs) 
throws IOException {
         return new IndexNode("foo", defn, createSampleDirectory(numOfDocs));
     }

Modified: 
jackrabbit/oak/branches/1.2/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java?rev=1680171&r1=1680170&r2=1680171&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.2/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java
 (original)
+++ 
jackrabbit/oak/branches/1.2/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java
 Tue May 19 05:31:12 2015
@@ -67,6 +67,8 @@ import static org.apache.jackrabbit.oak.
 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.PathFilter.PROP_EXCLUDED_PATHS;
+import static 
org.apache.jackrabbit.oak.plugins.index.PathFilter.PROP_INCLUDED_PATHS;
 import static 
org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.INCLUDE_PROPERTY_NAMES;
 import static 
org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.ORDERED_PROP_NAMES;
 import static 
org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.PROP_NODE;
@@ -377,7 +379,7 @@ public class LucenePropertyIndexTest ext
 
         Tree test = root.getTree("/").addChild("test");
         test.addChild("a").setProperty("tags", of("a","b"), Type.STRINGS);
-        test.addChild("b").setProperty("tags", of("a","c"), Type.STRINGS);
+        test.addChild("b").setProperty("tags", of("a", "c"), Type.STRINGS);
         root.commit();
 
         String q = "SELECT * FROM [nt:unstructured] as content WHERE 
ISDESCENDANTNODE('/content/dam/en/us')\n" +
@@ -496,6 +498,50 @@ public class LucenePropertyIndexTest ext
     }
 
     @Test
+    public void pathInclude() throws Exception{
+        Tree idx = createIndex("test1", of("propa", "propb"));
+        idx.setProperty(createProperty(PROP_INCLUDED_PATHS, of("/test/a"), 
Type.STRINGS));
+        //Do not provide type information
+        root.commit();
+
+        Tree test = root.getTree("/").addChild("test");
+        test.addChild("a").setProperty("propa", 10);
+        test.addChild("a").addChild("b").setProperty("propa", 10);
+        test.addChild("c").setProperty("propa", 10);
+        root.commit();
+
+        assertThat(explain("select [jcr:path] from [nt:base] where [propa] = 
10"), containsString("lucene:test1"));
+
+        assertQuery("select [jcr:path] from [nt:base] where [propa] = 10", 
asList("/test/a", "/test/a/b"));
+    }
+
+    @Test
+    public void pathExclude() throws Exception{
+        Tree idx = createIndex("test1", of("propa", "propb"));
+        idx.setProperty(createProperty(PROP_EXCLUDED_PATHS, of("/test/a"), 
Type.STRINGS));
+        //Do not provide type information
+        root.commit();
+
+        Tree test = root.getTree("/").addChild("test");
+        test.addChild("a").setProperty("propa", 10);
+        test.addChild("a").addChild("b").setProperty("propa", 10);
+        test.addChild("c").setProperty("propa", 10);
+        root.commit();
+
+        assertThat(explain("select [jcr:path] from [nt:base] where [propa] = 
10"), containsString("lucene:test1"));
+
+        assertQuery("select [jcr:path] from [nt:base] where [propa] = 10", 
asList("/test/c"));
+
+        //Make some change and then check
+        test = root.getTree("/").getChild("test");
+        test.addChild("a").addChild("e").setProperty("propa", 10);
+        test.addChild("f").setProperty("propa", 10);
+        root.commit();
+
+        assertQuery("select [jcr:path] from [nt:base] where [propa] = 10", 
asList("/test/c", "/test/f"));
+    }
+
+    @Test
     public void determinePropTypeFromRestriction() throws Exception{
         Tree idx = createIndex("test1", of("propa", "propb"));
         //Do not provide type information


Reply via email to