Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
I'm writing a Groovy builder for Compass (Lucene) queries, and it would be nice to use + and - in the closure, since it mirrors Lucene's own query string syntax, eg:
def query = builder.build { +term('keywords', 'book') -term('keywords', 'audio') queryString('color theory') }
would create a query that in Lucene query string syntax looks like +keywords:book -keywords:audio all:color all:theory.
(Incidentally this query means: 'keywords' MUST have the value 'book' and MUST NOT have the value 'audio' and 'all' SHOULD (may or may not) have 'color' and 'theory'.)
Ok they don't mirror each other exactly, but for those familar with Lucene query string syntax I think this will just feel "right".
So can these + and - operators be made interceptable method calls?
I think the opinion of the list was to use positive() and negative() as the method names: http://www.nabble.com/use-of-%2B-and---in-DSL--tf3623677.html