[Xapian-discuss] Expanding the search in PHP

Daniel Ménard Daniel.Menard at ehesp.fr
Thu Apr 23 08:56:27 BST 2009


Frank J Bruzzaniti a écrit :
> I tried using the simpleexpand.php from 
> http://xapian.org/docs/bindings/php/examples/simpleexpand.php5
>
> I get different results between PHP and the Omega expand (see below), 
> I'd like to have the same functionality in PHP.
> Could anyone suggest how to do it? Is there an example I could use?
>   
Omega uses a custom ExpandDecider which rejects some terms during the 
expansion (terms with prefixes and stems among other things).
See end of file 
http://trac.xapian.org/browser/trunk/xapian-applications/omega/query.cc

Currently, you can't write such an ExpandDecider with the PHP bindings 
(IIRC, this is because Swig/php is missing a feature named "directors" 
which allows to pass a php class to xapian).

As a poor workaround, you can change simpleexpand.php5 and ask for more 
terms (e.g. $eset = $enquire->get_eset(50, $rset);) and then filter the 
list or terms to display only those you want.

This is, of course, less efficient and you won't be able to guarantee 
how many terms the final list will have.

A better option would be to have a C++ utility class in the php bindings 
(e.g. SimpleExpandDecider) which would ignore terms starting with given 
prefixes (similar to SimpleStopper)... Badly, I'm not a C coder and I 
miss time...

Just my two cents...

Best regards,

Daniel



More information about the Xapian-discuss mailing list