searching for " in phrase and other special chars

Olly Betts olly at survex.com
Tue Feb 14 00:15:00 GMT 2017


On Wed, Feb 08, 2017 at 08:51:53PM +0000, Eric Wong wrote:
> Hello,
> 
> I'm reading xapian-core/docs/queryparser.rst and haven't been
> able to find a way to escape " (double-quote) inside quoted
> phrases.
> 
> Is this possible?

For boolean terms, you can escape double-quote by doubling it.

But for phrases it doesn't make much sense unless your terms contain
double quotes.  But TermGenerator treats a double quote as a word
separator, and QueryParser's behaviour is aligned with that.

> I'm also wondering if searching for other special characters,
> such as a literal '*', is possible without triggering a wildcard
> match.  It would be helpful for some source code searches.

You can include "*" in a boolean term, but for probabilistic terms you
can't - and TermGenerator similarly treats '*' as a word separator.

You really need compatible definitions of what a word is at indexing
and search time, so if you're doing indexing without TermGenerator with a
radically different definition of what a "word" is, you'll currently need
to also eschew QueryParser and parse queries yourself.

Cheers,
    Olly



More information about the Xapian-discuss mailing list