'How to debug an Elasticsearch painless script

I am currently trying to debug a script written in the Elasticsearch "painless" scripting language. This script is stored on the cluster and using parameters to update a document by ID. It is working fine when called through the ES dev console. However, when calling it from Java with the exact same parameters and same doc ID, I am not getting the expected results. The document simply remains unchanged.

Regardless of how the update happens exactly (which is using our own Kafka based update pipelines): What are good approaches to debug such a stored script? How can I log debug output and exceptions and where exactly would these log messages be showing up? Thanks!

final Map<String, Object> params = <my parameters here>;                
final Script script = new Script(ScriptType.STORED, null, MY_SCRIPT_NAME, params);              
UpdateRequest updateRequest = new UpdateRequest(MY_INDEX_NAME, ES_ID_OF_DOC).script(script);

// updateRequest then sent to ES via Kafka or via BulkIndexService
// neither of which leads to the desired doc update


Solution 1:[1]

As it turns out, the error was in the Kafka consumer. A first version of this script was throwing an exception from which the consumer was not able to recover, so it was stuck in an endless loop, preventing all further processing.

Still, if anyone has some hints on how to best debug painless scripts, feel free to add them here.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 martin_wun