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

Field.StringTokenStream#end() does not call super.end()

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.6
    • 4.6.1, 4.7, 6.0
    • core/other
    • None
    • New, Patch Available

    Description

      Field.StringTokenStream#end() currently does not call super.end(). This prevents resetting the PositionIncrementAttribute to 0 in end(), which can lead to wrong positions in the index under certain conditions.

      I added a test to TestDocument which indexes two Fields with the same name, String values, indexed=true, tokenized=false and IndexOptions.DOCS_AND_FREQS_AND_POSITIONS. Without the fix the test fails. The first token gets the correct position 0, but the second token gets position 2 instead of 1. The reason is that in DocInverterPerField line 176 (which is just after the call to end()) we increment the position a second time, because end() didn't reset the increment to 0.

      All tests pass with the fix.

      Attachments

        1. lucene-5401.patch
          5 kB
          Michael Busch

        Activity

          People

            michaelbusch Michael Busch
            michaelbusch Michael Busch
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: