You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Oliver Hutchison <oh...@aconex.com> on 2006/08/10 09:49:31 UTC
NPE when sorting on a field that is missing from a doc
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
RE: NPE when sorting on a field that is missing from a doc
Posted by Oliver Hutchison <oh...@aconex.com>.
> i havne't seen it mentioned before ... i'm guessing it is
> specific to the "explicit Locale" String comparator.
I've created an issue (LUCENE-650) with patch to fix this.
Thanks,
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: NPE when sorting on a field that is missing from a doc
Posted by Chris Hostetter <ho...@fucit.org>.
: 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):
: >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.
that is correct .. typically "no value" is interpreted as being the
"lowest possible value" (so in a reverse sort, they appear at the end of
the list and not the begining)
: Is this a know issue? If not I'll raise the issue and create a patch.
i havne't seen it mentioned before ... i'm guessing it is specific to the
"explicit Locale" String comparator.
-Hoss
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org