i have two domain class like this :
class ExhibitionPrint {
Exhibition exhibition
Print print
String title
String description
....
static searchable = {
printSizes component: true
exhibition component: true
}
}
And
class Exhibition {
String title
boolean isPublished
....
static hasMany = [exhibitionPrints: ExhibitionPrint]
static searchable = {
exhibitionPrints component: true
}
}
I used a closure in the search but it doesn't seem to work, I get results even when exhibition.isPublished is equal to false. I have something like this:
def searchResult = ExhibitionPrint.search{
must{
queryString(query)
term("ExhibitionPrint.exhibition.isPublished", true)
}
}.results
Any idea how to implement this?
The query you've created interprets to, essentially:
MUST match (query OR isPublished = true)
, or, using lucene's syntax+(query isPublished:true)
If I understand correctly, what you want is that it must match both clauses (that is:
+query +ispublished:true
), so something like: