You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ch...@apache.org on 2014/10/16 15:39:24 UTC

svn commit: r1632303 - /jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java

Author: chetanm
Date: Thu Oct 16 13:39:24 2014
New Revision: 1632303

URL: http://svn.apache.org/r1632303
Log:
OAK-2198 - Add support for declaringNodeTypes to only index node with specific types

Make nodeType based query conditional untill we have proper support for nodeType indexing

Modified:
    jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java

Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java?rev=1632303&r1=1632302&r2=1632303&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java (original)
+++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java Thu Oct 16 13:39:24 2014
@@ -548,7 +548,7 @@ public class LucenePropertyIndex impleme
     private static void addNonFullTextConstraints(List<Query> qs,
             Filter filter, IndexReader reader, Analyzer analyzer, IndexDefinition indexDefinition) {
         if (!filter.matchesAllTypes()) {
-            addNodeTypeConstraints(qs, filter);
+            addNodeTypeConstraints(indexDefinition, qs, filter);
         }
 
         String path = filter.getPath();
@@ -874,14 +874,19 @@ public class LucenePropertyIndex impleme
         qs.add(bq);
     }
 
-    private static void addNodeTypeConstraints(List<Query> qs, Filter filter) {
+    private static void addNodeTypeConstraints(IndexDefinition defn, List<Query> qs, Filter filter) {
         BooleanQuery bq = new BooleanQuery();
-        //TODO These condition should only be added if those propertyTypes are indexed
-        for (String type : filter.getPrimaryTypes()) {
-            bq.add(new TermQuery(new Term(JCR_PRIMARYTYPE, type)), SHOULD);
+        //TODO OAK-2198 Add proper nodeType query support
+        if (defn.includeProperty(JCR_PRIMARYTYPE)) {
+            for (String type : filter.getPrimaryTypes()) {
+                bq.add(new TermQuery(new Term(JCR_PRIMARYTYPE, type)), SHOULD);
+            }
         }
-        for (String type : filter.getMixinTypes()) {
-            bq.add(new TermQuery(new Term(JCR_MIXINTYPES, type)), SHOULD);
+
+        if (defn.includeProperty(JCR_MIXINTYPES)) {
+            for (String type : filter.getMixinTypes()) {
+                bq.add(new TermQuery(new Term(JCR_MIXINTYPES, type)), SHOULD);
+            }
         }
         qs.add(bq);
     }