[Xapian-devel] Sort ordering

Olly Betts olly at survex.com
Tue Sep 21 14:07:22 BST 2010


On Mon, Aug 23, 2010 at 09:42:41PM +1000, Simon Litchfield wrote:
> Using MultiValueSorter, I can sort by key1, key2, relevance; or relevance,
> key1, key2.
> 
> But AFAIK, I can't sort by key1, relevance, key2. Unless I spool out the
> entire result set or write some C++.

Indeed you can't.

Incidentally, note that sorting by keys after relevance is rarely useful with
BM25Weight (the default) as documents don't often get exactly the same score.
It can be useful with custom weighting schemes (which can only be implemented
in C++) or perhaps with carefully chosen BM25 parameters.

> I wonder if we need a new 'sort by' function that accepts any combination of
> keys and relevance in any order? The function would make it's own
> optimisations (ie is relevance first or last, etc)

Perhaps this would be best done by adding a couple of methods to allow a
pre-relevance sorter and a post-relevance sorter to be set.  Not sorting
by relevance at all would be done by:

    enquire.set_weighting_scheme(Xapian::BoolWeight());

The current set_sort_by_* methods could then be implemented in terms of
this new API.

Cheers,
    Olly



More information about the Xapian-devel mailing list