lucene-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: Result order when no sort defined
Date Mon, 02 May 2011 22:27:08 GMT
: I'm doing a query where it pulls back a collection of results based upon a
: list of id values.  eg:
	....
: This query returns the results in a consistent order, but I can't discern
: how it works out that order.
: 
: About half of the results all come back with a score of 0.5912891 and then
: some others have a lower 0.55549824 and the last one has 0.53078187.
: 
: id is a string field and each of these should be an exact match.

the specifics of you you executed the search (ie: what API you used and 
what your code looks like) are important.   At the lowest level, docs come 
back in "index order" by default -- that historicly has been the order 
they were put into the index, but as Lucene evolves and new merge 
algorithms are added it may not always been true.

based on what you're describing however, it's possible you are using a 
TopDocs based API which returns them sorted by score.

The real question is why the docs don't all have identical scores ... the 
score explanation feature should help you understand that.  the details 
really depend on wether there are any docs with the same id value (even if 
they are deleted) and how the id value is indexed. (and if there are doc 
boosts, etc...)

: I'm trying to get them returned in the order that the ids are defined in the
: query.  eg.  +(id:a or id:b or id:c) returns a list of [a,b,c]

i don't know of any simple way to do that with lucene scoring.  if these 
are "unique keys" and you know in advance the upper bound number of docs 
you'll get back (ie: the number of ids) and you want them all at once (ie: 
no pagination) then it's pretty trivial to sort them in the client.


-Hoss

Mime
View raw message