[Xapian-discuss] How does the sorting of search result work in Xapian?

Olly Betts olly at survex.com
Thu Apr 5 14:59:51 BST 2007


On Thu, Apr 05, 2007 at 09:55:36AM -0400, Ram Peters wrote:
> I have fields in the database for title, description, and created_at.
> I am using this to create document to be indexed.
> 
> I want to sort the result in DESENDING order of CREATED_AT.  Do I do
> this on database level, or after the result retrieved from the
> database.  Do I have to manually sort them, using some sorting
> algorithms?

Add "created_at" as a value (Document::add_value()).

Then you can sort them during the match - see
Enquire::set_sort_by_value() (or set_sort_by_value_then_relevance() if
multiple documents are likely to have the same value and you want to
sort by relevance within groups with the same value).

Cheers,
    Olly



More information about the Xapian-discuss mailing list