On 20/05/11 19:26, Steven A Rowe wrote:
      cat +dog -fox

Selects documents which must contain "dog" and must not contain "fox".
Documents will rank higher if "cat" is present, but it is not required."

I would have expected such behaviour, whatever "Default Operator" as
been defined.

But it seems that I need to use the Default Operator OR to have this
behaviour, which breaks our current requirement (we want default
operator AND if no operators are precised in the query).

Restating: you want default AND behavior when the query contains no operators, 
and default OR behavior when the query *does* contain operators.

This is not supported by the Lucene QueryParser.

Ok,


IS there anyway to achieve this ? Or do I need to extend myself the
queryparser contrib ?

A workaround may be to simply look for "+" and "-" in the query under one of the following 
conditions: preceded either by "(" or " ", or at the beginning of the string, e.g. using a regex 
like /(?:^|[\s(])[+-]/, and if you find a match, use default OR operator, and if not, use default AND operator?

Ok, thanks for the workaround.

--
Renaud Delbru

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to