Painless: Restructure/Clean Up of Spec Documentation (#31013)
Full restructure of the spec into new sections for operators, statements, scripts, functions, lambdas, and regexes. Split of operators into 6 sections, a table, reference, array, numeric, boolean, and general. Clean up of all operators sections. Sporadic clean up else where.
2018-06-07 20:11:56 -04:00
|
|
|
[[painless-statements]]
|
|
|
|
=== Statements
|
|
|
|
|
|
|
|
Painless supports all of Java's https://docs.oracle.com/javase/tutorial/java/nutsandbolts/flow.html[
|
|
|
|
control flow statements] except the `switch` statement.
|
|
|
|
|
2019-10-03 15:22:48 -04:00
|
|
|
==== Conditional statements
|
|
|
|
|
|
|
|
===== If / Else
|
|
|
|
|
|
|
|
[source,painless]
|
|
|
|
---------------------------------------------------------
|
|
|
|
if (doc[item].size() == 0) {
|
|
|
|
// do something if "item" is missing
|
|
|
|
} else {
|
|
|
|
// do something else
|
|
|
|
}
|
|
|
|
---------------------------------------------------------
|
|
|
|
|
|
|
|
==== Loop statements
|
|
|
|
|
|
|
|
===== For
|
|
|
|
|
Painless: Restructure/Clean Up of Spec Documentation (#31013)
Full restructure of the spec into new sections for operators, statements, scripts, functions, lambdas, and regexes. Split of operators into 6 sections, a table, reference, array, numeric, boolean, and general. Clean up of all operators sections. Sporadic clean up else where.
2018-06-07 20:11:56 -04:00
|
|
|
Painless also supports the `for in` syntax from Groovy:
|
|
|
|
|
|
|
|
[source,painless]
|
|
|
|
---------------------------------------------------------
|
|
|
|
for (item : list) {
|
|
|
|
...
|
|
|
|
}
|
2019-10-03 15:22:48 -04:00
|
|
|
---------------------------------------------------------
|