jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alessandro Bologna <alessandro.bolo...@gmail.com>
Subject Issue with aggregate index when child node has a reference or weakreference property.
Date Mon, 01 Jul 2013 01:23:42 GMT
seems that there's an issue with the way that properties of type
reference (weak or not) are dealt with in the case of an aggregate
index. I have tested this on jackrabbit 2.4.4.
For an nt:file node, with jcr:content of type nt:unstructured, I have
the following indexing aggregate:

<aggregate primaryType="nt:file">

If I add a property, say foo of type weakreference, as soon as the
session is saved I get a null pointer exception in
This is the offending line:

TokenStream tokenStream = field.tokenStreamValue();  // returns null
value for a field of type reference
TermAttribute termAttribute = tokenStream.addAttribute(TermAttribute.class);

I can see the problem even when running the IndexingAggregateTest (see
the patch file at the end), as long as I set a break point in Eclipse
for NPE and run the test in debug mode.

Please note that if the
<include-property>jcr:content/jcr:lastModified</include-property> line
is omitted, this problem doesn't occur (and order by
jcr:content/jcr:lastModified searches are still working). But reading
https://issues.apache.org/jira/browse/JCR-2302 and Marcel's comment
that only in the case of include-property the SimpleScoreDocComparator
is used, I would think that performance would suffer otherwise.

Is this a bug, or maybe I am doing something wrong?
Thanks for the help.


### Eclipse Workspace Patch 1.0
#P jackrabbit-core
Index: src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingAggregateTest.java
--- src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingAggregateTest.java
(revision 1498201)
+++ src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingAggregateTest.java
(working copy)
@@ -16,8 +16,10 @@
 package org.apache.jackrabbit.core.query.lucene;

+import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Node;
+import javax.jcr.nodetype.NodeType;
 import javax.jcr.query.Query;

 import java.io.ByteArrayOutputStream;
@@ -100,6 +102,10 @@
     public void testContentLastModified() throws RepositoryException {
         List expected = new ArrayList();
         long time = System.currentTimeMillis();
+        if (!testRootNode.isNodeType(NodeType.MIX_REFERENCEABLE)) {
+         testRootNode.addMixin(NodeType.MIX_REFERENCEABLE);
+        }
+        testRootNode.save();
         for (int i = 0; i < 10; i++) {
             expected.add(addFile(testRootNode, "file" + i, time));
             time += 1000;
@@ -131,7 +137,7 @@
         checkResultSequence(q.execute().getRows(), (Node[])
expected.toArray(new Node[expected.size()]));

-    public void disabled_testPerformance() throws RepositoryException {
+    public void testPerformance() throws RepositoryException {
         createNodes(testRootNode, 10, 4, 0, new NodeCreationCallback() {
             public void nodeCreated(Node node, int count) throws
                     RepositoryException {
@@ -159,13 +165,17 @@
     private static Node addFile(Node folder, String name, long lastModified)
             throws RepositoryException {
         Node file = folder.addNode(name, "nt:file");
-        Node resource = file.addNode("jcr:content", "nt:resource");
+        Node resource = file.addNode("jcr:content", "nt:unstructured");
         Calendar cal = Calendar.getInstance();
         resource.setProperty("jcr:lastModified", cal);
         resource.setProperty("jcr:encoding", "UTF-8");
         resource.setProperty("jcr:mimeType", "text/plain");
         resource.setProperty("jcr:data", new
+        assertEquals(
+         resource.setProperty("ref",
+         folder.getPath());
         return file;

View raw message