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/31 07:14:08 UTC

svn commit: r1635681 - in /jackrabbit/oak/branches/1.0: ./ oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java

Author: chetanm
Date: Fri Oct 31 06:14:08 2014
New Revision: 1635681

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

Modified:
    jackrabbit/oak/branches/1.0/   (props changed)
    jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java

Propchange: jackrabbit/oak/branches/1.0/
------------------------------------------------------------------------------
  Merged /jackrabbit/oak/trunk:r1632303

Modified: jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java?rev=1635681&r1=1635680&r2=1635681&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java (original)
+++ jackrabbit/oak/branches/1.0/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java Fri Oct 31 06:14:08 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);
     }