lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler (JIRA)" <>
Subject [jira] [Commented] (LUCENE-3390) Incorrect sort by Numeric values for documents missing the sorting field
Date Wed, 21 Sep 2011 08:21:09 GMT


Uwe Schindler commented on LUCENE-3390:

Doron: That's exactly the problem. This easy use case is problematic:

You allow sorting by Price. The user can switch between forward and backward sorting. In all
cases, you want all articles without a price at the beginning. To achieve this, you have to
set the price value e.g. to negative_infinity for the forward sorting, but positive_infinity
for backwards sorting. If now two users are using your user interface in parallel, they collide.

The fix used here is identical to Lucene trunk and we should keep the code similar. FieldComparator
is now almost identical between trunk and 3.x (except the new BytesRef/Docvalues stuff in

Thinking more about it: Another apporoach (also possible for trunk) is to supply the missing
value to FieldCache.getXxx(). The FieldCache would the first use Arrays.fill() to populate
the FieldCache array with the default value and after that populate the index values. The
drawback is that you get a separate FieldCache entry for each distinct missing value. For
the above se case, you would have two float/double price caches.

> Incorrect sort by Numeric values for documents missing the sorting field
> ------------------------------------------------------------------------
>                 Key: LUCENE-3390
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: core/search
>    Affects Versions: 3.3
>            Reporter: Gilad Barkai
>            Assignee: Doron Cohen
>            Priority: Minor
>              Labels: double, float, int, long, numeric, sort
>             Fix For: 3.4
>         Attachments: LUCENE-3390-fix-like-trunk.patch, LUCENE-3390-fix-like-trunk.patch,
LUCENE-3390-fix-like-trunk.patch, LUCENE-3390.patch,
> While sorting results over a numeric field, documents which do not contain a value for
the sorting field seem to get 0 (ZERO) value in the sort. (Tested against Double, Float, Int
& Long numeric fields ascending and descending order).
> This behavior is unexpected, as zero is "comparable" to the rest of the values. A better
solution would either be allowing the user to define such a "non-value" default, or always
bring those document results as the last ones.
> Example scenario:
> Adding 3 documents, 1st with value 3.5d, 2nd with -10d, and 3rd without any value.
> Searching with MatchAllDocsQuery, with sort over that field in descending order yields
the docid results of 0, 2, 1.
> Asking for the top 2 documents brings the document without any value as the 2nd result
- which seems as a bug?

This message is automatically generated by JIRA.
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message