[Xapian-discuss] Re: Query / Database question
Olly Betts
olly at survex.com
Tue Feb 27 15:21:08 GMT 2007
On Tue, Feb 27, 2007 at 11:29:13AM +0000, Ross Lawley wrote:
> $xapian_stemmer = new XapianStem("english");
> $xapian_query_parser = new XapianQueryParser;
> $xapian_query_parser->set_stemmer($xapian_stemmer);
> $xapian_query_parser->set_stemming_strategy (0);
It's better to use the named constants here - the underlying values are
an implementation detail, and it's not impossible that they could
change.
Currently 0 means "STEM_NONE", which it probably not what you want since
you're also setting a stemming language.
> However, with that query I never return any results - yet I know there are
> items indexed with the XTYPE value of 11.
I suspect that the terms being added don't match those that the
queryparser is generating a query for.
You can see if XTYPE11 is in the document using delve:
delve /path/to/database -t XTYPE11.
By default delve currently stems terms with the english stemmer, so
appending a "." prevents this. This is really a misfeature that ought
to be fixed.
If it isn't, look at a document to find out the terms which are there:
delve /path/to/database -r 1
If that's OK, look at the query you're getting from the QueryParser:
echo $xapian_query->get_description();
> Also, I'm looping the search terms and expanding them so that a search for
> "zulu" would become "title:zulu OR description:zulu" Should I be doing
> that, searching for just "zulu" doesn't return any results.
I would usually just index the terms both with their prefix and without
one:
title: index=S index
description: index=XDESC index
> Also on a side note is there any way to add more weighting to results that
> match the title over the description?
You can either increase the wdf of terms from the title at index time
using "weight=N" for some integer N > 1, for example:
title: weight=3 index=S index
Or you can set the within query frequency (wqf) at query time, but
that's not currently possible using the QueryParser class.
Cheers,
Olly
More information about the Xapian-discuss
mailing list