繁体   English   中英

Grails可搜索插件添加到索引条件

[英]Grails Searchable plugin add to index condition

我有网域:

class Listing {
  String name
  Address address
  static searchable = {
    address component: true
    only: ['name']
  }
  static constraints = {
    address nullable: true
  }
}

我想在搜索索引中只包含地址!= null的对象。 通过配置可以实现吗?

Lucene不能那样工作。 您只能按存在的字段和值进行搜索,并且不能直接检查该字段是否存在,SQL的“ is null”检查不能在此处完成。 要实现所需的功能,您必须添加类似boolean addressPresent ,如果地址已填满,则将其设置为true 然后在查询中,您必须添加其他子句以检查addressPresent字段

暂无
暂无

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

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