开发者

grails searchable index null value

开发者 https://www.devze.com 2023-04-01 10:04 出处:网络
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.

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.


  1. You can try Mapping the Dealer as component. So that dealer is contained within the Classified's index for easy searching.
  2. 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"
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号