Is there any site or method to make sandbox with Painless?
Can I test the scripts as if it were the javascript language?
How can I test my scripts?
For example in some functions I wondered if the value is correct.
boolean isCategory(def proposal, def matching) {
int length = String.valueOf(1000).length();
// I like test value of length with echo o sandbox os smilar
// Some code
return true
}
The best way to test your scripts is by running them against a local instance of Elasticsearch.
Painless doesn't have a REPL or online sandbox or anything, partly because context is so important to the scripts and partly because we haven't built one. By context I mean that a script that works in an update may not work in filter query or a script field. They have very different things available to them.
OTOH examples like your function would run fine in an "empty" context. This falls more into the category of "we haven't built it". And we may never build it because of the context issue.
And, no you can't really write javascript and expect it to work in painless. Painless is kind of like Java and kind of like Groovy in syntax. Lots of groovy is valid painless. Most painless is valid groovy.
I think the simplest way to test painless is with an index with a single document, a search that matches all documents, and a script field. The script field lets you return a value and you can see it in the results.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.