Uploaded image for project: 'Lucene.Net'
  1. Lucene.Net
  2. LUCENENET-394

AnonymousClassScoreDocComparator throws nullreferenceexception

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Environment:

      Lucene.NET 2.4.0.2

      Description

      I've added a field to my index (Store.NO, Index.UN_TOKENIZED), I've updated a couple of my documents and I'm now sorting on it (after I collected document id's in a HitCollector). My search results in some documents that consist of document with the field and without.

      I use a simple implementation of SortComparator which implements GetComparable by just returning the passed termtext.

      I've set a breakpoint at my GetComparable method and I see the correct values (the method is NOT called for documents that don't have the field as a value).

      When SortComparer.Compare is called, a NullReferenceException occurs in:

      public virtual int Compare(ScoreDoc i, ScoreDoc j)
      {
          return this.cachedValues[i.doc].CompareTo(this.cachedValues[j.doc]);
      }
      

      The expression this.cachedValues[i.doc] is null.

      Is this a limitation of SortComparer (and its AnonymousClassScoreDocComparator) that all documents in a searchresult need to have a value for the field??

        Attachments

          Activity

            People

            • Assignee:
              slombard Scott R. Lombard
              Reporter:
              q42jaap Jaap Taal
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: