As I understand it, sorting by field is what caches are all
about. You have a big list in memory of all of the terms for
a field, indexed by Lucene doc ID so fetching the term to
compare by doc ID is fast, and also why the caches need
to be warmed, and why sort fields should be single-valued.

If you try to do this yourself and fetch data from each document,
you can incur a huge performance hit, since you'll be seeking
all over your disk...

Score is special though since it's transient. Internally, all Lucene
has to do is keep track of the top N scores encountered where
N is something like "start + queryResultWindowSize", this
latter from solrconfig.xml, with no seeks to disk at all...

Best
Erick

On Tue, Apr 19, 2011 at 2:50 PM, Jonathan Rochkind <rochk...@jhu.edu> wrote:
> On 4/19/2011 1:43 PM, Jan Høydahl wrote:
>>
>> Hi,
>>
>> Not possible :)
>> Lucene compares each matching document against the query and produces a
>> score for each.
>> Documents are not compared to eachother like normal sort, that would be
>> way too costly.
>
> That might be true for sort by 'score' (although even if you have all the
> scores, it still seems like some kind of sort must be neccesary to see which
> comes first), but when you sort by a field value, which is also possible,
> Lucene must be doing some kind of 'normal sort' algorithm, no?  Ah, I guess
> it could just be using each term's position in the index, which is available
> in constant time, always kept track of in an index? Maybe, I don't know?
>
>
>

Reply via email to