I am using the Searchable plugin's query builder to try and build a query that searches some content and only returns objects that the user is the audience of or the audience is global. The code I would like to have would be similar to:
{
term("content", content)
or {
term('reach', 'global')
term('audience$user', User)
}
}
But there is no 'or' for this, how do I say that I want one of my field to have a term AND have one of two other conditions met with the searchable's query builder DSL?
This seems like a dumb question, but I've been searching for quite a while and can't find an answer.
I would use the grammar of the searchable plugin:
search("+content:${content} +(reach:global OR audience.user.id:${user.id})")
Not sure what you meant with 'audience$user' though.
Look here for details: http://grails.org/Searchable+Plugin+-+Searching+-+String+Queries http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Boolean%20operators