[Xapian-discuss] time bias/sorting

Olly Betts olly at survex.com
Tue Jul 11 19:07:59 BST 2006


On Tue, Jul 11, 2006 at 10:20:11AM +0100, Joss Shaw wrote:
> Am I right in thinking that Xapian has some nascant interface for
> sorting or biasing results by a Unix timestamp value stored in a
> document ?

For biasing results, yes.  The interface for sorting on a value is
very usable - I wouldn't describe that as nascent.

Rusty Conover is (or was) working on an "ExternalPostList" which is
actually very close to what is needed to implement MatchBiasFunctor:

http://thread.gmane.org/gmane.comp.search.xapian.devel/741

I don't know what the current status of that is.

> I've been through the documentation but I can't seem to
> confirm this.  I see in a previous email to this list that you can add
> three terms with the prefixes "D", "M" and "Y" - but I'm not sure if
> these actually help sort/bias results.  Is there a fourth prefix which
> allows me to store a timestamp ?

You want to store the timestamp in a document value, not as a term.
Use something like:

    document.add_value(0, timestamp);

> I've also discovered $enq->set_bias(); but I'm not entirely clear on
> its options.  In some sample code I see set_bias(0, 86400);  I guess
> 86400 is 24 hours in seconds, but what exactly does it do ?

It's the half-life.  The extra weight decays exponentially with age, so
an article 1 day old will get half the extra weight that a brand new
article will; an article 2 days old will get 1/4 of the weight, etc.

Cheers,
    Olly



More information about the Xapian-discuss mailing list