[Xapian-discuss] Result Priorities

Olly Betts olly at survex.com
Thu Sep 9 23:31:17 BST 2004


On Tue, Aug 24, 2004 at 05:14:27PM -0400, Mike Boone wrote:
> I have a document search where certain documents are given a priority value.
> Currently the priority is only 1 or 0, but it could possibly include a
> couple more levels. I would like my search results to place the higher
> priorty documents first (as long as it matches the search terms), even if a
> lower priorty document has a higher relevance from the search terms. Using
> my MySQL-based search, I just do a reverse sort on the priority level before
> I sort on the relevance. [snip]
> 
> What's the best way to implement this in Xapian?

OK, as of Xapian 0.8.2 (which'll probably be out on Monday) the answer
is to store the priority in a value, say number 1, at indexing time
like this:

    doc.add_value(1, priority);

Then tell enquire to sort by value 1, then by relevance:

    enquire.set_sorting(1, 1, true);

This will work for many priority levels.

Cheers,
    Olly



More information about the Xapian-discuss mailing list