[Xapian-discuss] Stemming and field prefixes

Mark Blythe list at markblythe.com
Wed Mar 28 06:23:14 BST 2007


Ah, thanks, that explains it.  It turns out that I actually did want the
non-stemming behavior.  I was just expecting to have to battle the stemming
behavior, and I was surprised when it didn't stem.  It's good to know the
reason behind it.

Thanks!

On 3/27/07, Olly Betts <olly at survex.com> wrote:
>
> 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