lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dror Matalon <d...@zapatec.com>
Subject NPE when using explain
Date Thu, 04 Dec 2003 01:51:59 GMT

Hi,

I'm trying to use IndexSearcher.explain(Query query, int doc) and am
getting a NPE. If I remove the "explain" the search works fine.
I poked a little at the TermQuery.java code, but I can't really tell
what's causing the exception.

This is with 1.3rc3


Exception in thread "main" java.lang.NullPointerException at
org.apache.lucene.search.TermQuery$TermWeight.explain(TermQuery.java:142) at
org.apache.lucene.search.BooleanQuery$BooleanWeight.explain(BooleanQuery.java:186) at
org.apache.lucene.search.IndexSearcher.explain(IndexSearcher.java:196)
at LuceneCli.search(LuceneCli.java:78)
at LuceneLine.handleCommand(LuceneLine.java:188)
at LuceneLine.<init>(LuceneLine.java:117)
at LuceneLine.main(LuceneLine.java:136)

The area of the code that caused this.

    Hits hits = initSearch(queryString);
    System.out.println(hits.length() + " total matching documents");

    final int HITS_PER_PAGE = 10;
    message ("--------------------------------------");
    for (int start = 0; start < hits.length(); start += HITS_PER_PAGE) {
      int end = Math.min(hits.length(), start + HITS_PER_PAGE);
      for (int ii = start; ii < end; ii++) {
        Document doc = hits.doc(ii);
        message ("---------------- " + ii + " score:" + hits.score(ii) + "---------------------");
        if (explain) {
          Explanation exp = searcher.explain(query, ii);
          message("Explanation:" + exp.toString());
        }
        printHit(doc);
      }


Regards,

Dror

-- 
Dror Matalon
Zapatec Inc 
1700 MLK Way
Berkeley, CA 94709
http://www.fastbuzz.com
http://www.zapatec.com

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message