lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Busch (JIRA)" <>
Subject [jira] Updated: (LUCENE-1327) TermSpans skipTo() doesn't always move forwards
Date Thu, 19 Mar 2009 16:15:50 GMT


Michael Busch updated LUCENE-1327:

    Attachment: lucene-1327.patch

I think the right fix here is to simply remove these lines:
// are we already at the correct position?
if (doc >= target) { return true; }

Then TermSpans#skipTo() basically returns what the TermPositions#skipTo() call returns.
TermPositions#skipTo() has the same semantics as described in the javadocs of Spans#skipTo().

The patch I'm attaching contains a junit that fails before applying the fix, and passes after
applying. All other tests pass too.

Any objections here? Otherwise I'll commit in a day or two.

> TermSpans skipTo() doesn't always move forwards
> -----------------------------------------------
>                 Key: LUCENE-1327
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Query/Scoring, Search
>    Affects Versions: 1.9, 2.0.0, 2.1, 2.2, 2.3, 2.3.1, 2.3.2, 2.4
>            Reporter: Moti Nisenson
>            Assignee: Michael Busch
>            Priority: Minor
>             Fix For: 2.9
>         Attachments: lucene-1327.patch
> In TermSpans (or the anonymous Spans class returned by SpansTermQuery, depending on the
version), the skipTo() method is improperly implemented if the target doc is less than or
equal to the current doc:
>   public boolean skipTo(int target) throws IOException {
>           // are we already at the correct position?
>           if (doc >= target) {
>             return true;
>           }
>           ...
> This violates the correct behavior (as described in the Spans interface documentation),
that skipTo() should always move forwards, in other words the correct implementation would
> if (doc >= target) {
>   return next();
> }
> This bug causes particular problems if one wants to use the payloads feature - this is
because if one loads a payload, then performs a skipTo() to the same document, then tries
to load the "next" payload, the spans hasn't changed position and it attempts to load the
same payload again (which is an error).

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

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

View raw message