简体   繁体   中英

Including boolean property check in Search Query builder with Grails Searchable Plugin

I am trying to limit my search criteria to return entities with a boolean property set to true. For example

class Product {
  def name
  Boolean enabled
}

How can I do it using a search query builder, my simple search so far is:

Product.search(query, analyzer: 'whitespace')

I tried using query builder with term but it does not work:

Product.search {
  must(queryString(query))
  must(term('enabled',true))
}

Any ideas? Thank you.

It'll be the spelling error ("available" vs. "enabled").

According to this thread anyway, your syntax is correct.

I was using 0.5.5.1 version of searchable plugin. After updating to the latest 0.6 SNAPSHOT enabled field is being picked up like it supposed to and results are accurate. Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM