jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1581483 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate/ oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/ oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugi...
Date Tue, 25 Mar 2014 19:41:24 GMT
Author: alexparvulescu
Date: Tue Mar 25 19:41:23 2014
New Revision: 1581483

URL: http://svn.apache.org/r1581483
Log:
OAK-1613 Node aggregation over multiple levels does't work

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate/SimpleNodeAggregator.java
    jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
    jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate/SimpleNodeAggregator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate/SimpleNodeAggregator.java?rev=1581483&r1=1581482&r2=1581483&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate/SimpleNodeAggregator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/aggregate/SimpleNodeAggregator.java
Tue Mar 25 19:41:23 2014
@@ -62,7 +62,7 @@ public class SimpleNodeAggregator implem
             for (String inc : r.includes) {
                 // check node name match
                 if (name.equals(getName(inc))) {
-                    levelsUp = 1;
+                    levelsUp = getDepth(inc);
                     primaryType.add(r.primaryType);
                     if (acceptStarIncludes) {
                         break;

Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java?rev=1581483&r1=1581482&r2=1581483&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
Tue Mar 25 19:41:23 2014
@@ -79,7 +79,6 @@ import org.apache.lucene.index.MultiFiel
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.TermsEnum;
-import org.apache.lucene.queries.mlt.MoreLikeThis;
 import org.apache.lucene.queryparser.classic.ParseException;
 import org.apache.lucene.queryparser.classic.QueryParser;
 import org.apache.lucene.search.BooleanClause;

Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationTest.java?rev=1581483&r1=1581482&r2=1581483&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationTest.java
(original)
+++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationTest.java
Tue Mar 25 19:41:23 2014
@@ -75,9 +75,9 @@ public class LuceneIndexAggregationTest 
      * 
      */
     private static NodeAggregator getNodeAggregator() {
-        return new SimpleNodeAggregator().newRuleWithName(NT_FILE,
-                newArrayList(JCR_CONTENT, JCR_CONTENT + "/*")).newRuleWithName(
-                NT_FOLDER, newArrayList("myFile"));
+        return new SimpleNodeAggregator()
+            .newRuleWithName(NT_FILE, newArrayList(JCR_CONTENT, JCR_CONTENT + "/*"))
+            .newRuleWithName(NT_FOLDER, newArrayList("myFile", "subfolder/subsubfolder/file"));
     }
 
     /**
@@ -255,6 +255,38 @@ public class LuceneIndexAggregationTest 
     }
 
     @Test
+    public void testNodeTypesDeep() throws Exception {
+
+        Tree folder = root.getTree("/").addChild("myFolder");
+        folder.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, Type.NAME);
+
+        Tree folder2 = folder.addChild("subfolder");
+        folder2.setProperty(JCR_PRIMARYTYPE, "nt:unstructured", Type.NAME);
+
+        Tree folder3 = folder2.addChild("subsubfolder");
+        folder3.setProperty(JCR_PRIMARYTYPE, "nt:unstructured", Type.NAME);
+        file(folder3, "file");
+
+        root.commit();
+
+        String xpath = "//element(*, nt:folder)[jcr:contains(., 'dog')]";
+        assertQuery(xpath, "xpath", ImmutableList.of("/myFolder"));
+    }
+
+    private static void file(Tree parent, String name) {
+        Tree file = parent.addChild(name);
+        file.setProperty(JCR_PRIMARYTYPE, NT_FILE, Type.NAME);
+
+        Tree resource = file.addChild(JCR_CONTENT);
+        resource.setProperty(JCR_PRIMARYTYPE, "nt:resource", Type.NAME);
+        resource.setProperty("jcr:lastModified", Calendar.getInstance());
+        resource.setProperty("jcr:encoding", "UTF-8");
+        resource.setProperty("jcr:mimeType", "text/plain");
+        resource.setProperty(binaryProperty(JCR_DATA,
+                "the quick brown fox jumps over the lazy dog."));
+    }
+
+    @Test
     public void testChildNodeProperty() throws Exception {
         Tree file = root.getTree("/").addChild("myFile");
         file.setProperty(JCR_PRIMARYTYPE, NT_FILE, Type.NAME);



Mime
View raw message