lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Hutchison" <ohutchi...@aconex.com>
Subject NPE when sorting on a field that is missing from a doc
Date Thu, 10 Aug 2006 07:49:31 GMT
Hi all, 

we have recently noticed that doing a locale sensitive sort on a field that
is missing from some docs causes an NPE inside the call to Collator#compare
at FieldSortedHitQueue line 320 (Lucene 2.0 src):

static ScoreDocComparator comparatorStringLocale (final IndexReader reader,
final String fieldname, final Locale locale)
  throws IOException {
    final Collator collator = Collator.getInstance (locale);
    final String field = fieldname.intern();
    final String[] index = FieldCache.DEFAULT.getStrings (reader, field);
    return new ScoreDocComparator() {

      public final int compare (final ScoreDoc i, final ScoreDoc j) {
		return collator.compare (index[i.doc], index[j.doc]);  <----
NPE in compare call one/both param null 
      }


>From looking at the standard String, float and int sorting and reading
LUCENE-406 I assume this in not expected behavior and that docs that do not
include the field should be sorted to appear at the start of the list of
results.

Is this a know issue? If not I'll raise the issue and create a patch.

Thanks again,

Oliver



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message