简体   繁体   English

如何调试 Elasticsearch 无痛脚本

[英]How to debug an Elasticsearch painless script

I am currently trying to debug a script written in the Elasticsearch "painless" scripting language.我目前正在尝试调试用 Elasticsearch “无痛”脚本语言编写的脚本。 This script is stored on the cluster and using parameters to update a document by ID.此脚本存储在集群上,并使用参数按 ID 更新文档。 It is working fine when called through the ES dev console.通过 ES 开发控制台调用时它工作正常。 However, when calling it from Java with the exact same parameters and same doc ID, I am not getting the expected results.但是,当使用完全相同的参数和相同的文档 ID 从 Java 调用它时,我没有得到预期的结果。 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?不管更新是如何发生的(使用我们自己的基于 Kafka 的更新管道):调试此类存储脚本的好方法是什么? How can I log debug output and exceptions and where exactly would these log messages be showing up?我如何记录调试 output 和异常以及这些日志消息究竟会显示在哪里? 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

As it turns out, the error was in the Kafka consumer.事实证明,错误出在 Kafka 消费者中。 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.尽管如此,如果有人对如何最好地调试无痛脚本有一些提示,请随时将它们添加到此处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM