简体   繁体   English

使用Grails可搜索插件在“搜索查询”构建器中包括布尔属性检查

[英]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. 我试图将搜索条件限制为返回布尔属性设置为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: 我尝试将查询生成器与term一起使用,但不起作用:

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. 我正在使用0.5.5.1版本的可搜索插件。 After updating to the latest 0.6 SNAPSHOT enabled field is being picked up like it supposed to and results are accurate. 更新到最新的0.6 SNAPSHOT启用字段后,将像预期的那样拾取该字段,结果是准确的。 Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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