Lucene - Core
  1. Lucene - Core
  2. LUCENE-2336

off by one: DisjunctionSumScorer::advance

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core/search
    • Labels:
    • Lucene Fields:
      New

      Description

      The bug is:

      if (target <= currentDoc) {

      should be

      if (target < currentDoc) {

      based on the comments for the method as well as the contract for DocIdSetIterator: "Advances to the first beyond the current"

      It can be demonstrated by:

      assertEquals("advance(1) first match failed", 1, scorer.advance(1));
      assertEquals("advance(1) second match failed", n, scorer.advance(1));

      if docId: 1 is a hit and n is the next hit. (Tests all pass if this code change is made.)

      I'm not labeling it as major because the class is package-protected and currently passes spec.

      Relevant excerpt:

      /**

      • Advances to the first match beyond the current whose document number is
      • greater than or equal to a given target. <br>
      • When this method is used the {@link #explain(int)}

        method should not be

      • used. <br>
      • The implementation uses the skipTo() method on the subscorers.
      • @param target
      • The target document number.
      • @return the document whose number is greater than or equal to the given
      • target, or -1 if none exist.
        */
        public int advance(int target) throws IOException {
        if (scorerDocQueue.size() < minimumNrMatchers) { return currentDoc = NO_MORE_DOCS; }

        if (target <= currentDoc)

        { return currentDoc; }

        do {
        if (scorerDocQueue.topDoc() >= target)

        { boolean b = advanceAfterCurrent(); return b ? currentDoc : (currentDoc = NO_MORE_DOCS); }

        else if (!scorerDocQueue.topSkipToAndAdjustElsePop(target))

        Unknown macro: { if (scorerDocQueue.size() < minimumNrMatchers) { return currentDoc = NO_MORE_DOCS; } }

        } while (true);
        }

        Activity

        Gary Yngve created issue -
        Mark Thomas made changes -
        Field Original Value New Value
        Workflow jira [ 12502431 ] Default workflow, editable Closed status [ 12563452 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12563452 ] jira [ 12584926 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Gary Yngve
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Time Tracking

              Estimated:
              Original Estimate - 4h
              4h
              Remaining:
              Remaining Estimate - 4h
              4h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development