Ivo Jansch - Ibuildings
2009-May-17  10:09 UTC
[Xapian-discuss] Need some help with spelling suggestions
Hi,
I have trouble getting the spelling suggestion feature to work when I 
use multiple search terms.
If I use:
$qp->set_default_op(XapianQueryParser::FLAG_LOVEHATE);
$query = $qp->parse_query($queryString)
It works fine when I search for e.g. 'hello world'
However, changing this to:
$qp->set_default_op(XapianQueryParser::FLAG_LOVEHATE | 
XapianQueryParser::FLAG_SPELLING_CORRECTION);
       $query = $qp->parse_query($queryString)
I now end up with the following error:
[17-May-2009 11:57:50] PHP Fatal error:  Uncaught exception 'Exception' 
with message 'InvalidOperationError: get_min_subqs called with invalid 
operator type' in /Applications/MAMP/bin/php5/lib/php/xapian.php:1408
Stack trace:
#0 /Applications/MAMP/bin/php5/lib/php/xapian.php(1408): 
queryparser_parse_query(Resource id #132, 'hello world')
Am I doing something wrong, or is spelling correction not supported for 
queries that have multiple terms?
Greetings,
Ivo
Olly Betts
2009-May-17  15:03 UTC
[Xapian-discuss] Need some help with spelling suggestions
On Sun, May 17, 2009 at 12:09:31PM +0200, Ivo Jansch - Ibuildings wrote:> $qp->set_default_op(XapianQueryParser::FLAG_LOVEHATE | > XapianQueryParser::FLAG_SPELLING_CORRECTION); > $query = $qp->parse_query($queryString)set_default_op() takes an "OP", not a combination of "FLAGs" - e.g. XapianQuery::OP_AND - so you're setting a totally bogus value for the default op here. With just FLAG_LOVEHATE you happen to set a valid op value so you don't get an exception, but you won't get the behaviour you expect. The correct code for this is: $query = $qp->parse_query($queryString, XapianQueryParser::FLAG_LOVEHATE | XapianQueryParser::FLAG_SPELLING_CORRECTION); The error which is reported could be better - I'll take a look at that. Cheers, Olly