I'm working on a Grails project that uses the ElasticSearch plugin for
Grails. The author of the plugin has done a great job, but I've encountered
an issue that I believe is rooted in the XContentBuilder class used to
build the JSON to index my domain class.
In the plugin, the code determines a suitable marshaller for an object
based on its class. It would appear that for most of the standard classes,
this equates to using the plugins DefaultMarshaller, which effectively
calls XContentBuilder.field(String name, >Class of object< object).
Unfortunately looking at the ES source, there is no field(String,
BigDecimal) so it seems the default is called - field(String, Object),
which simply calls toString() on the class and as a result my JSON renders
a String instead of a numeric value for the BigDecimal, which is for a
price field in my domain class. This causes the indexing to fail for some
reason (which I haven't quite figured out what yet).
Is there a reason BigDecimal isn't overloaded? What approach should I use -
I've forked the ES Grails plugin code and am happy to make whatever changes
might be needed there and do a push request to the author.