lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joel Bernstein (JIRA)" <>
Subject [jira] [Updated] (LUCENE-5682) NPE in QueryRescorer when Scorer is null
Date Mon, 19 May 2014 11:48:38 GMT


Joel Bernstein updated LUCENE-5682:

    Attachment: LUCENE-5682.patch

Quick patch. It's a little tough to read due to some code indenting but basically I just wrapped
a null check around this block of code:

      if(scorer != null) {
        int targetDoc = docID - docBase;
        int actualDoc = scorer.docID();
        if (actualDoc < targetDoc) {
          actualDoc = scorer.advance(targetDoc);

        if (actualDoc == targetDoc) {
          // Query did match this doc:
          hit.score = combine(hit.score, true, scorer.score());
        } else {
          // Query did not match this doc:
          assert actualDoc > targetDoc;
          hit.score = combine(hit.score, false, 0.0f);

Looks like we need to check for a null scorer on each hit because the segment could change
with each hit. I didn't follow through with a combine is this situation as you did on a miss
hit, but we could if you want to.

> NPE in QueryRescorer when Scorer is null
> ----------------------------------------
>                 Key: LUCENE-5682
>                 URL:
>             Project: Lucene - Core
>          Issue Type: Bug
>    Affects Versions: 4.8
>            Reporter: Joel Bernstein
>            Assignee: Joel Bernstein
>         Attachments: LUCENE-5682.patch
> While testing out the QueryRescorer I was getting an NPE on the scorer  when using a
TermQuery as the rescore query. Looks like a TermQuery will return a null Scorer if  the term
is not present in the index segment.
> Caused by: java.lang.NullPointerException
>    [junit4]    > 	at

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message