[Xapian-discuss] Need some help with spelling suggestions
Ivo Jansch - Ibuildings
ivo at ibuildings.nl
Sun May 17 17:01:02 BST 2009
Hello Olly,
ah thanks, I confused 'op' with 'option' instead of 'operator'.
With your suggested code, I no longer get an error message.
(However, I'm not getting anything back from get_corrected_query_string,
see debug output at my dev env:
http://www.flackr.epointment.com/search?query=individauls
Code looks like this now:
$qp = new XapianQueryParser();
$stemmer = new XapianStem("english");
$qp->set_stemmer($stemmer);
$qp->set_database($database);
$qp->set_stemming_strategy(XapianQueryParser::STEM_SOME);
$query = $qp->parse_query($queryString,
XapianQueryParser::FLAG_LOVEHATE|XapianQueryParser::FLAG_SPELLING_CORRECTION);
$correction = $qp->get_corrected_query_string();
Thanks,
Ivo
Olly Betts schreef:
> 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
>
--
Ibuildings [i]
THE PHP PROFESSIONALS
*ing. Ivo Jansch*
CTO (Zend PHP5 Certified)
mobile: +31 (0) 6 44 99 86 23
skype: ivo-ibuildings <callto://ivo-ibuildings>
e-mail: ivo at ibuildings.nl <mailto:ivo at ibuildings.nl>
phone: +31 (0) 88 00 24 000
www.ibuildings.nl <http://www.ibuildings.nl>
To all agreements with Ibuildings.nl BV, our general terms and
conditions <http://www.ibuildings.com/ibuildings/av> apply.
More information about the Xapian-discuss
mailing list