[英]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.