Hi, this looks like a bug. can you please open a jira issue and describe how to reproduce the problem. I'd also be interested to know if this also happens with the most recent version of Jackrabbit.
Regards Marcel > -----Original Message----- > From: Alessandro Bologna [mailto:alessandro.bolo...@gmail.com] > Sent: Montag, 1. Juli 2013 03:24 > To: users@jackrabbit.apache.org > Subject: Issue with aggregate index when child node has a reference or > weakreference property. > > Hi, > 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"> > <include>jcr:content</include> > <include-property>jcr:content/jcr:lastModified</include-property> > </aggregate> > > If I add a property, say foo of type weakreference, as soon as the > session is saved I get a null pointer exception in > org.apache.jackrabbit.core.query.lucene.SearchIndex.mergeAggregatedNod > eIndexes. > 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. > > Alessandro > > > ### Eclipse Workspace Patch 1.0 > #P jackrabbit-core > Index: > src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingAggregate > Test.java > ========================================================== > ========= > --- > src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingAggregate > Test.java > (revision 1498201) > +++ > src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingAggregate > Test.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(); > cal.setTimeInMillis(lastModified); > resource.setProperty("jcr:lastModified", cal); > resource.setProperty("jcr:encoding", "UTF-8"); > resource.setProperty("jcr:mimeType", "text/plain"); > resource.setProperty("jcr:data", new > ByteArrayInputStream("test".getBytes())); > + assertEquals( > + resource.setProperty("ref", > folder.getSession().getValueFactory().createValue(folder,true)).getNode().g > etPath(), > + folder.getPath()); > + > return file; > }