[Xapian-discuss] Wildcard Query Help
Olly Betts
olly at survex.com
Wed Mar 21 10:36:01 GMT 2007
On Wed, Mar 14, 2007 at 03:39:10PM +0000, Colin Bell wrote:
> I've got a setting where I would like to do wildcard searches. I see
> that this can only be done with a Xapian::QueryParser and I am
> currently using Xapian::Query.
>
> I tried to change my code over but when I change it to a
> Xapian::QueryParser it stops working. Now out of shear ignorance on
> my part, I've simply spaced my terms in a long string with spaces in
> between in the hopes that the QueryParser sorts them out. this might
> be my failure point. I have tried setting stemming to off etc.
You need to tell the QueryParser what user-visible prefix to map to
the term prefix Xterm:AUTHOR: by using the add_boolean_prefix() or
add_prefix() method:
http://www.xapian.org/docs/apidoc/html/classXapian_1_1QueryParser.html#5afd438f9901fbd5005a92161c61d1c8
But I wouldn't recommend trying to programmatically build strings to pass to
the QueryParser - it's designed to parse human entered strings.
If you want to expand a wildcard in other circumstances, it's more robust
to just use Database::allterms_begin() like the QueryParser does internally:
http://article.gmane.org/gmane.comp.search.xapian.general/1724
Cheers,
Olly
More information about the Xapian-discuss
mailing list