Skip to content

Commit f5ecfa4

Browse files
renshukijrodewig
authored andcommitted
[DOCS] Update painless statements with if/else example (#47485)
1 parent 8a77712 commit f5ecfa4

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

docs/painless/painless-statements.asciidoc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,28 @@
44
Painless supports all of Java's https://docs.oracle.com/javase/tutorial/java/nutsandbolts/flow.html[
55
control flow statements] except the `switch` statement.
66

7+
==== Conditional statements
8+
9+
===== If / Else
10+
11+
[source,painless]
12+
---------------------------------------------------------
13+
if (doc[item].size() == 0) {
14+
// do something if "item" is missing
15+
} else {
16+
// do something else
17+
}
18+
---------------------------------------------------------
19+
20+
==== Loop statements
21+
22+
===== For
23+
724
Painless also supports the `for in` syntax from Groovy:
825

926
[source,painless]
1027
---------------------------------------------------------
1128
for (item : list) {
1229
...
1330
}
14-
---------------------------------------------------------
31+
---------------------------------------------------------

0 commit comments

Comments
 (0)