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 al...@apache.org on 2013/09/06 10:37:14 UTC
svn commit: r1520512 - in /jackrabbit/oak/trunk:
oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchImpl.java
oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationTest.java
Author: alexparvulescu
Date: Fri Sep 6 08:37:14 2013
New Revision: 1520512
URL: http://svn.apache.org/r1520512
Log:
OAK-828 Full-text support for index aggregates
- included the case where a constraint on a child node's property should not return the aggregated parent
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchImpl.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/query/ast/FullTextSearchImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchImpl.java?rev=1520512&r1=1520511&r2=1520512&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchImpl.java Fri Sep 6 08:37:14 2013
@@ -187,9 +187,18 @@ public class FullTextSearchImpl extends
// and because we might not implement all features
// such as index aggregation
if (selector.index instanceof FulltextQueryIndex) {
+ // first verify if a property level condition exists and if that
+ // condition checks out, this takes out some extra rows from the index
+ // aggregation bits
+ if (relativePath == null && propertyName != null) {
+ PropertyValue p = selector.currentProperty(propertyName);
+ if (p == null) {
+ return false;
+ }
+ }
return true;
}
-
+
StringBuilder buff = new StringBuilder();
if (relativePath == null && propertyName != null) {
PropertyValue p = selector.currentProperty(propertyName);
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=1520512&r1=1520511&r2=1520512&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 Fri Sep 6 08:37:14 2013
@@ -246,11 +246,36 @@ public class LuceneIndexAggregationTest
root.commit();
- String matchContentSimple = "//*[(jcr:contains(., 'dog')) and @jcr:primaryType = 'nt:file']";
+ String matchContentSimple = "//*[( jcr:contains(., 'dog') and @jcr:primaryType = 'nt:file' )]";
assertQuery(matchContentSimple, "xpath", ImmutableList.of("/myFolder/myFile"));
- String matchContentDouble = "//*[(jcr:contains(., 'dog')) and (@jcr:primaryType = 'nt:file' or @jcr:primaryType = 'nt:folder')]";
+ String matchContentDouble = "//*[( jcr:contains(., 'dog') and (@jcr:primaryType = 'nt:file' or @jcr:primaryType = 'nt:folder') )]";
assertQuery(matchContentDouble, "xpath", ImmutableList.of("/myFolder", "/myFolder/myFile"));
}
+ @Test
+ public void testChildNodeProperty() throws Exception {
+ Tree file = root.getTree("/").addChild("myFile");
+ 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."));
+
+ resource.setProperty("jcr:title", "title");
+ resource.setProperty("jcr:description", "description");
+
+ root.commit();
+
+ String matchChildSimple = "//*[( jcr:contains(@jcr:title, 'title') )]";
+ assertQuery(matchChildSimple, "xpath", ImmutableList.of("/myFile/jcr:content"));
+
+ String matchChildWithStar = "//*[( jcr:contains(., 'dog') and jcr:contains(@jcr:title, 'title') )]";
+ assertQuery(matchChildWithStar, "xpath", ImmutableList.of("/myFile/jcr:content"));
+
+ }
+
}