Java Api for UpdateByQuery requests

OK, that was a bit of magic sauce I wasn't aware of. It got me a little further. Now getting write exception when attempting to write my custom objects. How do I pass the structures I want to update down to the script? Even if it's serializable, the script won't have access to the class itself. In the Sense playground, I can just create the JSON and magic happens. I tried turning it into JSON first, but then groovy script complains about strings not having the fields I'm looking for. What's the right way to pass in the correct object types?

Caused by: java.io.IOException: Can't write type [class com.triplet.store.impl.elasticsearch.dao.DomainTracking]
at org.elasticsearch.common.io.stream.StreamOutput.writeGenericValue(StreamOutput.java:420)
at org.elasticsearch.common.io.stream.StreamOutput.writeGenericValue(StreamOutput.java:380)
at org.elasticsearch.common.io.stream.StreamOutput.writeMap(StreamOutput.java:324)
at org.elasticsearch.script.Script.writeTo(Script.java:169)
at org.elasticsearch.common.io.stream.StreamOutput.writeOptionalStreamable(StreamOutput.java:472)
at org.elasticsearch.index.reindex.AbstractBulkIndexByScrollRequest.writeTo(AbstractBulkIndexByScrollRequest.java:70)
at org.elasticsearch.transport.netty.NettyTransport.sendRequest(NettyTransport.java:874)
at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:329)
at org.elasticsearch.action.TransportActionNodeProxy.execute(TransportActionNodeProxy.java:51)
at org.elasticsearch.client.transport.support.TransportProxyClient$1.doWithNode(TransportProxyClient.java:58)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:212)
at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:288)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:348)