[Xapian-discuss] Stemming and field prefixes

Olly Betts olly at survex.com
Wed Mar 28 04:44:56 BST 2007


On Tue, Mar 27, 2007 at 08:27:10PM -0700, Mark Blythe wrote:
> Sure, here's a sample Perl script:
> 
> use strict;
> use Search::Xapian qw(:standard);
> 
> my $stem = new Search::Xapian::Stem('english');
> my $qp = new Search::Xapian::QueryParser();
> 
> $qp->set_stemmer($stem);
> $qp->set_stemming_strategy(STEM_ALL);
> $qp->add_boolean_prefix('interest', 'I');
> 
> my $q = $qp->parse_query('limited interest:limited');
> print $q->get_description(), "\n";
> 
> When I run this, I get:
> 
> Xapian::Query((limit:(pos=1) FILTER Ilimited))
> 
> So, it stems "limited" as a regular query term, but not when prefixed.

Aha, QueryParser doesn't stem terms used in boolean prefixes.  A boolean
prefix is useful for something like a hostname, a language code, a file
type, etc and stemming isn't appropriate for these sort of things.

If you want the prefixed term stemmed, use a probabilistic prefix, not a
boolean prefix.  In your example, just change "add_boolean_prefix" to
"add_prefix".

Cheers,
    Olly



More information about the Xapian-discuss mailing list