AnsweredAssumed Answered

Lucene search fails with NullPointerException

Question asked by hbf on Dec 27, 2007
Latest reply on Dec 27, 2007 by hbf
Dear list,

I am performing a Lucene search like this:

TYPE:"kc:content" AND PATH:"/cm:generalclassifiable//cm:Foo//member" OR PATH:"/cm:generalclassifiable//cm:Bar//member"

This fails with the following exception:

java.lang.NullPointerException
Stack Trace:

    * org.apache.lucene.index.MultiTermDocs.doc(MultiReader.java:352)
    * org.alfresco.repo.search.impl.lucene.query.CachingTermPositions.doc(CachingTermPositions.java:116)
    * org.alfresco.repo.search.impl.lucene.query.LeafScorer.skipToMax(LeafScorer.java:457)
    * org.alfresco.repo.search.impl.lucene.query.LeafScorer.move(LeafScorer.java:498)
    * org.alfresco.repo.search.impl.lucene.query.LeafScorer.findNext(LeafScorer.java:434)
    * org.alfresco.repo.search.impl.lucene.query.LeafScorer.skipTo(LeafScorer.java:926)
    * org.alfresco.repo.search.impl.lucene.query.PathScorer.skipTo(PathScorer.java:194)
    * org.apache.lucene.search.BooleanScorer2$SingleMatchScorer.skipTo(BooleanScorer2.java:147)
    * org.apache.lucene.search.ReqOptSumScorer.score(ReqOptSumScorer.java:70)
    * org.apache.lucene.search.BooleanScorer2.score(BooleanScorer2.java:328)
    * org.apache.lucene.search.BooleanScorer2.score(BooleanScorer2.java:292)
    * org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:133)
    * org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:100)
    * org.apache.lucene.search.Hits.getMoreDocs(Hits.java:66)
    * org.apache.lucene.search.Hits.<init>(Hits.java:45)
    * org.apache.lucene.search.Searcher.search(Searcher.java:45)
    * org.apache.lucene.search.Searcher.search(Searcher.java:37)
    * org.alfresco.repo.search.impl.lucene.ADMLuceneSearcherImpl.query(ADMLuceneSearcherImpl.java:318)
    * org.alfresco.repo.search.SearcherComponent.query(SearcherComponent.java:85)
    * sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    * sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    * sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    * java.lang.reflect.Method.invoke(Method.java:585)
    * org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
    * org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
    * org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
    * net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:80)
    * org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
    * org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
    * org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
    * org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:241)
    * org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
    * org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
    * org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
    * org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
    * org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
    * $Proxy16.query(Unknown Source)

However, if I move to Disjunctive Normal Form, meaning:

(TYPE:"kc:content" AND  PATH:"/cm:generalclassifiable//cm:Foo//member") OR (TYPE:"kc:content" AND  PATH:"/cm:generalclassifiable//cm:Bar//member")

the query succeeds. The bug can be reproduced in the Node Browser.

It looks like a Lucene bug.

In order to work around these Lucene issues with Boolean queries, is there another efficient way to perform searches on type and categories?

Regards,
Kaspar

Outcomes