IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.

Statements

edit

Painless supports all of Java’s control flow statements except the switch statement.

Conditional statements

edit

If / Else

edit
if (doc[item].size() == 0) {
  // do something if "item" is missing
} else {
  // do something else
}

Loop statements

edit

For

edit

Painless also supports the for in syntax from Groovy:

for (item : list) {
  ...
}