Lucene - Core
  1. Lucene - Core
  2. LUCENE-3192

SortField.INT / SortField.FLOAT inconsistency with DocValues

    Details

    • Type: Wish Wish
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      When reviewing sorting by DocValues I found the following naming inconsistency, which shoulc be fixed.

      1. DocValues are always Longs or Doubles, but it uses SortField.INT and SortField.FLOAT
      2. If you enable docValues in SortField but not use not SortField.INT / SortField.FLOAT, it will use FieldCache without informing the user e.g. by Exception


      I would wish to fix this in any of the following ways:

      • as a comment TODO notes, create new types for docvalues and remove UseDocValues setter: SortField.INT_DOCVALUES, Sort.FLOAT_DOCVALUES (using the naming INT/FLOAT from the general DOCVALUES API). Ideally there should be also Sort.BYTESREF_DOCVALUES ? This would be more consistent, as getCompataor would be only a big switch as it was before.
      • use more "correct" SortField.LONG and SortField.DOUBLE and throw Exception if doc values is enabled, but a totally different SortField type is used. The Exception can be thrown in SortField.getComparator(). A second problem with SortField.INT instead of LONG is that when you request sort values to be filled into FieldDocs, the type there is suddenly Long, that may be totally confusing.
      • make SortField.LONG==SortField.INT(maybe also ==BYTE==SHORT) use also docvalues if enabled by using the same comparator. If DocValues incompatible type is used, throw Ex in getComparator()

      I would prefer solution #1, especially as I dont like SortField to be modifiable (useDocValues setter...). Solution #2 is also fine.

        Issue Links

          Activity

          Uwe Schindler created issue -
          Uwe Schindler made changes -
          Field Original Value New Value
          Assignee Simon Willnauer [ simonw ]
          Uwe Schindler made changes -
          Link This issue is related to LUCENE-3219 [ LUCENE-3219 ]
          Uwe Schindler made changes -
          Link This issue is related to LUCENE-3694 [ LUCENE-3694 ]
          Uwe Schindler made changes -
          Link This issue is duplicated by LUCENE-3862 [ LUCENE-3862 ]
          Uwe Schindler made changes -
          Link This issue relates to LUCENE-4033 [ LUCENE-4033 ]

            People

            • Assignee:
              Simon Willnauer
              Reporter:
              Uwe Schindler
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Development