Hightman(马明练)
2008-Jul-20 03:09 UTC
[Xapian-discuss] How can I write a MatchDecider in PHP-bindings?
Dose the xapian object allow to define a special MatchDecider in php-Bindings? If can, Is there any documents refer to? thanks much! Sometime, I need to put the new documents before the older documents when they have almost same relevance.
Olly Betts
2008-Jul-20 06:01 UTC
[Xapian-discuss] How can I write a MatchDecider in PHP-bindings?
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