Lucene - Core
  1. Lucene - Core
  2. LUCENE-5835

Add sortMissingLast support to TermValComparator

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.10, 6.0
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      It would be nice to allow to configure the behavior on missing values for this comparator, similarly to what TermOrdValComparator does.

      1. LUCENE-5835.patch
        25 kB
        Adrien Grand

        Activity

        Hide
        Adrien Grand added a comment -

        Here is a patch. I removed the notes about removing TermValComparator as it is the only way to sort a field that has binary doc values.

        Other than that:

        • it can now sort missing values last
        • you can override the terms and docsWithField that are used for comparison
        • you can override the detection for null values. This is typically useful if there is a sentinel value that represents null.

        I didn't add support for custom missing values as I'm not sure it is a common need on binary/string content but it is easy to implement on top of this comparator by overriding getDocsWithField to return a Bits.MatchAllBits set and wrap the binary dv returned by getBinaryDocValues.

        Show
        Adrien Grand added a comment - Here is a patch. I removed the notes about removing TermValComparator as it is the only way to sort a field that has binary doc values. Other than that: it can now sort missing values last you can override the terms and docsWithField that are used for comparison you can override the detection for null values. This is typically useful if there is a sentinel value that represents null. I didn't add support for custom missing values as I'm not sure it is a common need on binary/string content but it is easy to implement on top of this comparator by overriding getDocsWithField to return a Bits.MatchAllBits set and wrap the binary dv returned by getBinaryDocValues .
        Hide
        Robert Muir added a comment -

        +1

        Show
        Robert Muir added a comment - +1
        Hide
        ASF subversion and git services added a comment -

        Commit 1612245 from Adrien Grand in branch 'dev/trunk'
        [ https://svn.apache.org/r1612245 ]

        LUCENE-5835: TermValComparator can sort missing values last.

        Show
        ASF subversion and git services added a comment - Commit 1612245 from Adrien Grand in branch 'dev/trunk' [ https://svn.apache.org/r1612245 ] LUCENE-5835 : TermValComparator can sort missing values last.
        Hide
        ASF subversion and git services added a comment -

        Commit 1612249 from Adrien Grand in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1612249 ]

        LUCENE-5835: TermValComparator can sort missing values last.

        Show
        ASF subversion and git services added a comment - Commit 1612249 from Adrien Grand in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1612249 ] LUCENE-5835 : TermValComparator can sort missing values last.
        Hide
        ASF subversion and git services added a comment -

        Commit 1612881 from Adrien Grand in branch 'dev/trunk'
        [ https://svn.apache.org/r1612881 ]

        LUCENE-5835: Make TermValComparator extendable.

        Show
        ASF subversion and git services added a comment - Commit 1612881 from Adrien Grand in branch 'dev/trunk' [ https://svn.apache.org/r1612881 ] LUCENE-5835 : Make TermValComparator extendable.
        Hide
        ASF subversion and git services added a comment -

        Commit 1612882 from Adrien Grand in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1612882 ]

        LUCENE-5835: Make TermValComparator extendable.

        Show
        ASF subversion and git services added a comment - Commit 1612882 from Adrien Grand in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1612882 ] LUCENE-5835 : Make TermValComparator extendable.

          People

          • Assignee:
            Adrien Grand
            Reporter:
            Adrien Grand
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development