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

PagingFieldCollector fails when sorting by String null fields

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 4.1
    • None
    • core/search
    • New

    Description

      When performing a paginated search sorted by a STRING field, and documents without this field are present in the resultset, PagingFieldCollector stops collecting documents (or collects all documents, depending on sorting order) when one of the these documents are used as "after" element for the pagination.

      The reason i have observed is that:
      org.apache.lucene.search.FieldComparator.TermOrdValComparator.compareDocToValue(int doc, BytesRef value) (line 1160) always returns 1 in that case because value is null ("after" document sorting field value) whereas docValue (returned by termsIndex.getTerm) is a 0-length BytesRef for documents without that field.

      A simple patch can be performed changing only this method with no (apparently) side-effects:
      Current:
      if (docValue == null) {
      if (value == null) {
      Patched:
      if (docValue == null || docValue.length==0) {
      if (value == null || value.length==0) {

      Please excuse my lack of rigour, I'll try to attach the patch.
      Regards

      Attachments

        Activity

          People

            Unassigned Unassigned
            idelvall Ignacio del Valle Alles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: