In my Grails app, I have the following domain class that is indexed by the Searchable plugin:
class Foo implements Serializable {
BookletCategory bookletCategory
Date lastUpdated
static hasMany = [details: BookletRootDetail]
static searchable = {
bookletCategory component: true
id name: 'bookletRootId'
lastUpdated index: 'no'
}
}
When I retrieve instances of this class, the details property is always null, even though there are details instances in the database. My conclusion is that the details field is not being stored in the Lucene index. I tried adding this field to the index without making it a searchable property by adding the following to the searchable closure:
details index: 'no'
However it seems this is only valid for simple properties such as lastUpdated. Is there any way that I can ensure this property is populated when I retrieve instances of Foo from the index? Ideally I would like to do this without actually making details a searchable field?
I don't think you can do what you are trying to do. Assuming BookletRootDetail has a belongsTo clause (i.e. reference back to the parent), you could index the id, and make a second search query for the details corrsponding to the Foo's id.