質問

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:

search {
    must(queryString(query))
    must(term("ExhibitionPrint.exhibition.isPublished", true))
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top