Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-1583

SpanOrQuery skipTo() doesn't always move forwards

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.9, 2.0.0, 2.1, 2.2, 2.3, 2.3.1, 2.3.2, 2.4, 2.4.1
    • 2.9
    • core/search
    • None
    • New, Patch Available

    Description

      In SpanOrQuery the skipTo() method is improperly implemented if the target doc is less than or equal to the current doc, since skipTo() may not be called for any of the clauses' spans:

      public boolean skipTo(int target) throws IOException {
      if (queue == null)

      { return initSpanQueue(target); }

      while (queue.size() != 0 && top().doc() < target) {
      if (top().skipTo(target)) { queue.adjustTop(); } else { queue.pop(); }
      }

      return queue.size() != 0;
      }

      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 be:

      public boolean skipTo(int target) throws IOException {
      if (queue == null) { return initSpanQueue(target); }

      boolean skipCalled = false;
      while (queue.size() != 0 && top().doc() < target) {
      if (top().skipTo(target))

      { queue.adjustTop(); }

      else

      { queue.pop(); }

      skipCalled = true;
      }

      if (skipCalled)

      { return queue.size() != 0; }

      return next();
      }

      Attachments

        1. LUCENE-1583.patch
          2 kB
          Mark Miller
        2. LUCENE-1583.patch
          0.9 kB
          Mark Miller

        Activity

          People

            markrmiller@gmail.com Mark Miller
            motinis Moti Nisenson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: