[Xapian-discuss] Phrase Query vs AND Query? Why don't these find the same things?

Olly Betts olly at survex.com
Thu Jun 1 01:24:25 BST 2006


On Tue, May 30, 2006 at 09:06:48PM -0400, jarrod roberson wrote:
> given that I have done .add_posting() correctly with the LP: prefixed terms
> and the second AND Query returns the set of data I expect, why does the
> first query NOT return ANYTHING?

I can't reproduce this.  The attached python script finds one match (and
also does using quartz or flint instead of the inmemory backend).

So it seems the circumstances required to trigger this are somewhat
subtle.  Can you produce a self-contained example which shows this
similar to phrase.py?

> also what will ulimate be "better" given the context of these queries, the
> AND QUERY or the PHRASE QUERY?

I'm not sure I understand what you're trying to search for here.  But
generally a PHRASE query is better when the terms are only useful in
a particular order, or when there are common false positives which
includes all the terms but aren't relevant.

A phrase query is slower than an AND, so that's a reason to favour AND
if there's no other reason to pick one or the other.

Cheers,
    Olly
-------------- next part --------------
A non-text attachment was scrubbed...
Name: phrase.py
Type: text/x-python
Size: 599 bytes
Desc: not available
Url : http://lists.tartarus.org/pipermail/xapian-discuss/attachments/20060601/37fd1833/phrase.py


More information about the Xapian-discuss mailing list