[Xapian-discuss] exact text matching

Olly Betts olly at survex.com
Wed Nov 16 02:34:44 GMT 2005


On Tue, Nov 15, 2005 at 06:23:53PM -0800, Philip Neustrom wrote:
> How can I make Xapian return only results that contain the exact query
> string?  I want users to be able to "quote a string" and have that
> return only matches that contain that exact query.  What's the best
> way to do this?

Make sure you have built the index with positional information (use
Document::add_posting when indexing free text rather than
Document::add_term).

Then at search time, create a PHRASE query for the quoted string.  The
QueryParser class can handle this (and other common query parsing tasks)
for you.

Cheers,
    Olly



More information about the Xapian-discuss mailing list