Aha, oh well, not quite as good/flexible as I hoped.

Still, if lucene is now behaving somewhat more predictably/rationally when sorting on multi-valued fields, then I think, in response to your other email on a similar thread, perhaps SOLR-2339 is now a mistake.

When lucene was returning completely unpredictable results -- and even sometimes crashing entirely -- when sorting on a multi-valued field --- then I think in that situation it made a lot of sense for Solr to prevent you from doing that, which is I think what SOLR-2339 does? So I don't think it was neccesarily a mistake in that context.

But if lucene now can sort a multi-valued field without crashing when there are 'too many' unique values, and with easily described and predictable semantics (use the minimal value in the multi-valued field as sort key) -- then it probably makes more sense for Solr to let you do that if you really want to, give you enough rope to hang yourself.

Jonathan

On 3/17/2011 10:49 AM, Yonik Seeley wrote:
On Wed, Mar 16, 2011 at 6:08 PM, Jonathan Rochkind<rochk...@jhu.edu>  wrote:
Also... if lucene is already capable of sorting on multi-valued field by
choosing the largest value.... largest vs. smallest is presumably just
arbitrary there, there is presumably no performance implication to choosing
the smallest instead of the largest. It just chooses the largest, according
to Yonik.
It's a little more complicated than that.
It's not so much an explicit feature in lucene, but just what
naturally happens when building the field cache via uninverting an
indexed field.

It's pretty much this:

for every term in the field:
   for every document that matches that term:
     value[document] = term

And since terms are iterated from smallest to largest (and no, you
can't reverse this)
larger values end up overwriting smaller values.
There's no simple patch to pick the smallest rather than the largest.

In the past, lucene used to try and detect this multi-valued case by
checking the number of values set in the whole array.  This was
unreliable though and the check was discarded.

-Yonik
http://lucidimagination.com

Reply via email to