jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bae...@apache.org
Subject svn commit: r1590030 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java test/java/org/apache/jackrabbit/core/query/lucene/SQL2IndexingAggregateTest.java
Date Fri, 25 Apr 2014 13:58:40 GMT
Author: baedke
Date: Fri Apr 25 13:58:40 2014
New Revision: 1590030

URL: http://svn.apache.org/r1590030
Log:
JCR-3693: Lucene configuration - aggregation definition : problem with include-property tag

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/SQL2IndexingAggregateTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java?rev=1590030&r1=1590029&r2=1590030&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
Fri Apr 25 13:58:40 2014
@@ -33,6 +33,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.query.InvalidQueryException;
 import javax.xml.parsers.DocumentBuilder;
@@ -1552,14 +1553,18 @@ public class SearchIndex extends Abstrac
                                     String value = new String(termAttribute.termBuffer(),
0, termAttribute.termLength());
                                     if (value.startsWith(namePrefix)) {
                                         // extract value
-                                        value = value.substring(namePrefix.length());
+                                        String rawValue = value.substring(namePrefix.length());
                                         // create new named value
                                         Path p = getRelativePath(state, propState);
                                         String path = getNamespaceMappings().translatePath(p);
-                                        value = FieldNames.createNamedValue(path, value);
+                                        value = FieldNames.createNamedValue(path, rawValue);
                                         termAttribute.setTermBuffer(value);
+                                        PropertyMetaData pdm = PropertyMetaData
+                                                .fromByteArray(payloadAttribute
+                                                        .getPayload().getData());
                                         doc.add(new Field(field.name(),
-                                                new SingletonTokenStream(value, (Payload)
payloadAttribute.getPayload().clone())));
+                                                new SingletonTokenStream(value,
+                                                        pdm.getPropertyType())));
                                         doc.add(new Field(
                                                 FieldNames.AGGREGATED_NODE_UUID,
                                                 false,
@@ -1567,6 +1572,17 @@ public class SearchIndex extends Abstrac
                                                 Field.Store.NO,
                                                 Field.Index.NOT_ANALYZED_NO_NORMS,
                                                 Field.TermVector.NO));
+                                        if (pdm.getPropertyType() == PropertyType.STRING)
{
+                                            // add to fulltext index
+                                            Field ft = new Field(
+                                                    FieldNames.FULLTEXT,
+                                                    false,
+                                                    rawValue,
+                                                    Field.Store.YES,
+                                                    Field.Index.ANALYZED_NO_NORMS,
+                                                    Field.TermVector.NO);
+                                            doc.add(ft);
+                                        }
                                     }
                                 }
                             } finally {

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/SQL2IndexingAggregateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/SQL2IndexingAggregateTest.java?rev=1590030&r1=1590029&r2=1590030&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/SQL2IndexingAggregateTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/SQL2IndexingAggregateTest.java
Fri Apr 25 13:58:40 2014
@@ -353,4 +353,18 @@ public class SQL2IndexingAggregateTest e
                 + "]) and type = 'testnode' ";
         checkResult(qm.createQuery(sql, JCR_SQL2).execute(), 1);
     }
+
+    public void testAggregatedProperty() throws Exception {
+
+        Node parent = testRootNode.addNode("parent",
+                JcrConstants.NT_UNSTRUCTURED);
+        Node child = parent.addNode("child", JcrConstants.NT_UNSTRUCTURED);
+        child.setProperty("property",
+                "the quick brown fox jumps over the lazy dog.");
+        testRootNode.getSession().save();
+
+        String sql = "SELECT * FROM [nt:unstructured] as u WHERE CONTAINS (u.*, 'dog') ";
+        executeSQL2Query(sql, new Node[] { parent, child });
+    }
+
 }



Mime
View raw message