[Xapian-discuss] QueryParser: aliases and OP_AND
Richard Boulton
boulton.rj at googlemail.com
Wed Jan 20 15:52:31 GMT 2010
2010/1/19 Menard, Daniel <Daniel.Menard at ehesp.fr>:
> Hello,
>
> I'm wondering about how the QueryParser parses a query containing an "alias" when the default operator is OP_AND
> (by "alias", I mean a search field mapped to multiple term prefixes).
The short answer: it always combines each word of the options with
OP_OR, and there is no configuration for this currently.
I can see why it's not helpful in your situation, though. I can't
think of an easy solution inside the query parser, though. What you
want would seem to be to take each group of words in the query (ie,
each group of words not separated by an operator) and parse them with
each prefix, and then combine those options with OP_OR. We were
having some discussions on this subject on IRC recently - it would be
nice to have a way to specify how the queryparser deals with each set
of words it finds.
One workaround for you might be to parse the query multiple times,
each time using one of the prefixes for the field, and OR the
resulting queries together. This would produce the result you wanted
in the case of a search for "alias:(john smith)". This approach would
even work in the presence of other filters in the query. It would
fall down (or, at least, become overly complex) if you wanted multiple
expansions for more than one field, though.
> So my questions: is the current QueryParser's behaviour the intended one? Is there anything I can do to get the result I expect?
> Of course, the parsing is fine when default_op is OP_OR (as it is by default), but results are also "strange for me" if I try with OP_PHRASE:
>
> Xapian::Query(((AUT1:john:(pos=1) PHRASE 2 AUT1:smith:(pos=2)) OR (AUT2:john:(pos=1) PHRASE 2 AUT1:smith:(pos=2)) OR (AUT2:john:(pos=1) PHRASE 2 AUT2:smith:(pos=2)) OR (AUT1:john:(pos=1) PHRASE 2 AUT2:smith:(pos=2))))
This is the same problem, but looks a bit weirder because the query
has been rearranged by Xapian to put the PHRASE parts at the bottom of
the tree. (A OR B) PHRASE (C OR D) is equivalent to (A PHRASE C) OR
(A PHRASE D) OR (B PHRASE C) OR (B PHRASE D).
--
Richard
More information about the Xapian-discuss
mailing list