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

MultiSorter#sort incorrectly sort Integer/Long#MIN_VALUE when the natural sort is reversed

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 7.5, 8.0
    • 7.6, 8.0
    • None
    • None
    • New

    Description

      MultiSorter#getComparableProviders on an integer or long field doesn't handle MIN_VALUE correctly when the natural order is reversed. To handle reverse sort we use the negation of the value but there is no check for overflows so MIN_VALUE for ints and longs are always sorted first (even if the natural order is reversed).
      This method is used by index sorting when merging already sorted segments together. This means that a sorted index can be incorrectly sorted if it uses a reverse sort and a missing value set to MIN_VALUE (long or int or values inside the segment that are equals to MIN_VALUE).
      This a bad bug because it affects the documents order inside segments and only a reindex can restore the correct sort order.

      Attachments

        1. LUCENE-8592.patch
          82 kB
          Jim Ferenczi
        2. LUCENE-8592.patch
          84 kB
          Jim Ferenczi

        Activity

          People

            Unassigned Unassigned
            jim.ferenczi Jim Ferenczi
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: