I would like to build search query for Grails Searchable Plugin, which will return me only active objects. (Will not return objects with 'activate' flag set false). This is my situation.
I have one Abstract class, and some classes, which extend abstract class (e.g. Person):
class AbstractObject{
boolean active;
DateTime createDate
}
class Person extends AbstractObject{
String name;
String surname;
static searchable=[only:['name','surname','active']]
}
And when I delete object i set 'active' flag to false.
Before I was using
searchableService.search(myQuery, defaultOperator:"or", max: 10)
but it returns object which are inactive, so I decided to try with Query Builder:
def result=searchableService.search({
must(queryString(myQuery))
must(term('active',false))
}, defaultOperator:"or", max: 10)
Unforunately it returns nothing. Do you have any idea what am I doing wrong? How my code should look like?
Try following, I didn't test it. Hope it will resolve the issue.