Transform a groovy script to Java

Hi all,

I've written a groovy script that creates some new fields from the indexed data when indexing. This is a heavy operation and I've read that its faster when in Java. How can I accomplish this?

Thank you.

Edit: I'm using ES 1.7