Grails: Best practice indexing domain class


(Christian von Wendt-Jensen) #1

Hi,

What is the best way to index all fields of a Grails domain class?

The naive way is to copy the domain class field by field, but it would
be nice if you could just extract the properties of the document and
store them directly - kind of like:

class DocumentService {
...
def store(Document doc) {
def result = myClient.index {
index "csj"
type "doc"
id "$doc.id"
source {
complex {
doc.properties
}
}
}

    log.info("Doc stored: $result")

}

}

Thanks,

Christian von Wendt-Jensen


(system) #2