[Xapian-discuss] Searching using prefixes
Olly Betts
olly at survex.com
Wed Jul 27 13:59:38 BST 2011
On Wed, Jul 27, 2011 at 01:01:18PM +0100, Justin Finkelstein wrote:
> However, the documentation is a little unclear as to how this actually
> works - specifically, how I do a search for multiple words in just the
> title. For example, I have a title: "Research into Cheese in China".
> With the changes I have made to the indexer, I will have terms for this
> both without the S prefix and also WITH the S prefix to allow title-only
> searching.
>
> When it comes to searching, I want to be able to take the string "Cheese
> in China" as user input and pass this into the QueryParser and have it
> perform the search with the 'S' prefix added internally somehow. From
> the documentation, it looks like I do this:
>
> Xapian::QueryParser qp;
> qp.add_prefix("", "S");
> Xapian::Query query = qp.parse_query("Cheese in China");
Yes, that should work.
You can print out the query description to check what you got:
cout << query.get_description() << endl;
(If you want to see what terms have been generated by indexing to
compare, see the delve utility which is in xapian-core/examples.)
Any suggestions on how this could be made clearer in the docs?
Cheers,
Olly
More information about the Xapian-discuss
mailing list