grails searchable index null value
I'm trying to use searchable to find values by a null field. Or for that matter even index an id from a sub domain.
class Classified
{
searchable = {
only = ['id','title']
id name: 'classified_id'
title name: 'classified_title'
}
String title
Dealer dealer
}
class Dealer
{
String name
}
I want to just index the dealer_id that would exist in classifieds table to reference dealer. Then I want to be able to search classifieds by null dealer_id and numeric dealer_id. I 开发者_JAVA技巧tried making dealer searchable, but the problem with that is that if there is no dealer and classified.dealer_id is null it never even gets there.
- You can try Mapping the Dealer as component. So that dealer is contained within the Classified's index for easy searching.
- By default null values are not indexed and cannot be searched. So for the fields that you want to search for null values. Specifically tell searchable to index the null fields to other values (I use -1) and search for tht value.
Example,
static searchable = {
dealer componenet true
}
And Within the Dealer
static searchable = {
property nullValue "-1"
}
精彩评论