Key_script for histogram using java

Hello, everyone.

I am quite new with elasticsearch, but it is quite an interesting tool to
work with, indeed.

However, I encountered the following problem : I had to build a facet that
would tell me the number of docs indexed in the hours 0-2, 2-4, ... 22-24,
no matter the date.
I have a date field for this purpose.
I was able to find a way to do it in another thread, using an histogram
facet assorted with a key_script and a value_script. And that works great
with mobz.
My problem is that I must do it using the Java API, and I can't seem to
find a way to do it.
I can find a method to set a value_script, but nothing to set a key_script.
Is it even possible?

Thanks.
Deny

--