[Xapian-discuss] How can I write a MatchDecider in PHP-bindings?
Olly Betts
olly at survex.com
Sun Jul 20 07:01:33 BST 2008
On Sun, Jul 20, 2008 at 11:09:39AM +0800, Hightman(??????) wrote:
> Dose the xapian object allow to define a special MatchDecider in
> php-Bindings?
Unfortunately this isn't currently possible.
We use SWIG to produce the PHP bindings, and it doesn't currently
support a feature it calls "directors" for PHP, which is needed to
allow subclassing of wrapped classes.
I think it should be possible to implement, but nobody has done so
yet.
> Sometime, I need to put the new documents before the older documents
> when they have almost same relevance.
A MatchDecider only allows you to reject certain documents, not to
adjust weights. There's a new feature on Xapian's SVN trunk
(Xapian::PostingSource) which allows weights to be adjusted, but
again it isn't possible to subclass it in PHP currently.
One approach you could use from PHP would be to have a term which
identifies "new documents" - if you index them by the current week
number, then you could use the latest week number (or latest few). Then
combine your query with the "biasing" query like so:
// Could be OP_OR of several XWEEK terms...
$recent_query = new XapianQuery("XWEEK234");
// Adjust how much extra weight new documents get.
$bias = new XapianQuery(XapianQuery::OP_SCALE_WEIGHT, $recent_query,
$scale_factor);
$query = new XapianQuery(XapianQuery::OP_AND_MAYBE, $query, $bias);
Cheers,
Olly
More information about the Xapian-discuss
mailing list