[Xapian-discuss] PHP searches - not figuring it out

Matt Barnicle mattb at wageslavery.org
Wed Feb 7 08:39:00 GMT 2007


Hello everyone..  I'm new to using Xapian.  I'm having some troubles getting the php
querying to work.  Apologies, but I have a few different questions to ask and I'm not
sure in which way to order them.

I'm using php 4.3.9.

For starters, does anyone know of some good example php scripts that will do some more
advanced querying than is given in the sample "simplesearch.php"?

Through some testing and poking around it seems like the easiest solution to get going
is to use the QueryParser class..  It seems like the default feature flags it uses are
FLAG_BOOLEAN, FLAG_PHRASE and FLAG_LOVEHATE, but you have to specify if you want to use
FLAG_BOOLEAN_ANY_CASE or FLAG_WILDCARD.  Is that correct?  So, the flags I've listed as
the default ones all work well, except that all searches only work if I use the stemmed
version of the words.  Like if I want to search for "discover", I need to use "discov"
instead.  After finding out the stem I can do combinations with + and -, quotes, AND and
OR and it works well.

So, my next questions are, why do I have to use the stemmed words instead of their
originals when I use QueryParser?  Do I need to use the STEM_ALL strategy in order for
the QueryParser to convert each word into its stem?

I can't get wildcard searching to work, and I'm assuming that's because I need to set
FLAG_WILDCARD in the call to parse_query.  If that is the case, will I need to set all
the previous default flags as well as this one?

And now my next problem, which is actually the root of much of my troubles and why I
can't test all these ideas out for myself at the time..  This is a two part problem. 
First, I can't seem to get any of the enum constants to work in my php calls, like
STEM_ALL and FLAG_WILDCARD when using QueryParser or OP_AND when using Query.  When
using the Query class, I have tried using both OP_OR and Query_OP_OR, neither of which
work.  When using both of these methods, I get the error "No matching function for
overloaded 'new_XapianQuery'".  Here is the code for that:

version 1: $query = new XapianQuery(OP_OR, $terms);

version 2: $query = new XapianQuery(Query_OP_OR, $terms);

I also tried using the old non-OO method that is distributed in the simplesearch.php
script, and that doesn't work at all.  I get the message "Call to undefined function: 
new_query()" for this line of code:

$query = new_Query(Query_OP_OR, $terms);

So, I'm assuming that v0.9.9 only supports the OO style and not the original function
call style new_Query?  I can't get any of those functions to work, such as new_Database,
new_Enquire and new_Stem...

I also tried applying the following patch and recompiling, and I got the same error as
before:

http://www.oligarchy.co.uk/xapian/patches/xapian-php5-query-ctor-overload-fix.patch

Thanks for any assistance..  Sorry for the long post, but all my issues seem all kind of
related and I thought it necessary to explain in full...

- Matt




More information about the Xapian-discuss mailing list