Reputation: 1814
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.
Upvotes: 0
Views: 551
Reputation: 2959
This is a very late answer, but the correct way with the builder would be
{ must(term("content", content)) must { term('reach', 'global') term('audience$user', User) } }
apart from that I'm also not sure what you mean with audience$user.
See http://grails.1312388.n4.nabble.com/Searchable-plugin-s-query-builder-nested-or-query-td1388307.html
Upvotes: 0
Reputation: 6733
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
Upvotes: 2