Painless supports all of Java’s
control flow statements except the switch
statement.
Conditional statements
edit
if (doc[item].size() == 0) {
// do something if "item" is missing
} else if (doc[item].value == 'something') {
// do something if "item" value is: something
} else {
// do something else
}
Painless also supports the for in
syntax:
for (def item : list) {
// do something
}
for (item in list) {
// do something
}
while (ctx._source.item < condition) {
// do something
}
do {
// do something
}
while (ctx._source.item < condition)