[Xapian-devel] Initial patch for ExternalPostList

Olly Betts olly at survex.com
Sat Jun 3 21:01:11 BST 2006


On Sat, Jun 03, 2006 at 01:38:49PM -0600, Rusty Conover wrote:
> I'm interested in hearing more about how the actual weight would be
> returned for each document.

ExternalPostingSource would have the 2 methods get_weight() and
get_maxweight().  In response to a call to get_weight() it would
return the weight to contribute to the current document (i.e.
what get_docid() would currently return).

And a call to get_maxweight() would return an upper bound on what
get_weight() can return for any docid.

So to bias towards newer articles, you might have something like
this (which is pretty much what the current match bias stuff is
hardwired to do):

    In the ctor:

	W = some positive weight
	K = some negative constant which affects the decay rate
	now = time(NULL);

    Xapian::weight get_maxweight() const {
	return W;
    }

    Xapian::weight get_weight() const {
	time_t t = get_timestamp(get_docid());
	if (t >= now) {
	    return W;
	}
	t = now - t;
	return W * exp(K * t);
    }

If you only want to use the external source for filtering, both of these
can just return 0.

Cheers,
    Olly



More information about the Xapian-devel mailing list