[DOCS] Update painless statements with if/else example (#47485)
This commit is contained in:
parent
392013cf05
commit
dc02868671
|
@ -4,6 +4,23 @@
|
||||||
Painless supports all of Java's https://docs.oracle.com/javase/tutorial/java/nutsandbolts/flow.html[
|
Painless supports all of Java's https://docs.oracle.com/javase/tutorial/java/nutsandbolts/flow.html[
|
||||||
control flow statements] except the `switch` statement.
|
control flow statements] except the `switch` statement.
|
||||||
|
|
||||||
|
==== 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 also supports the `for in` syntax from Groovy:
|
Painless also supports the `for in` syntax from Groovy:
|
||||||
|
|
||||||
[source,painless]
|
[source,painless]
|
||||||
|
@ -11,4 +28,4 @@ Painless also supports the `for in` syntax from Groovy:
|
||||||
for (item : list) {
|
for (item : list) {
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue