[Xapian-discuss] Custom Stemmng and QueryParser

Mike Boone
2008-08-12T12:36:01Z

We're using Xapian 1.0.7.

I have an algorithm to pre-read a query and find words that we want to
stem differently than the standard stemming. These terms have a prefix
of XZ in the index.

However, when I prepend XZ on these terms and then use the
QueryParser, they resulting query shows the XZ as lowercase, combined
with my custom stem, and of course the term is not found.

Some code (PHP):

$xapStem=new XapianStem('english');
$xapQP=new XapianQueryParser();
$xapQP->set_database($this->xapDB);
$xapQP->set_stemmer($xapStem);
$xapQP->set_stemming_strategy(XapianQueryParser::STEM_SOME);
$xapQP->set_default_op(XapianQuery::OP_AND);
$iFlags=XapianQueryParser::FLAG_BOOLEAN |
XapianQueryParser::FLAG_PHRASE | XapianQueryParser::FLAG_PURE_NOT;
$xapQueryParsed=$xapQP->parse_query($strSearch,$iFlags);

I have the query "IIS and sharp". IIS is a custom stem, so the query
goes to the QueryParser as "XZiis and sharp". The QueryParser
translates this into Xapian::Query((xziis:(pos=1) AND
Zsharp:(pos=2))). But what I want is for that first term to look like
XZiis.

I'm not running any "add_prefix" commands before parsing the
query. Is
that necessary? In this case, I don't want the functionality where the
user can put in their own prefix with a colon.

Thanks for your input!
Mike Boone.