Statementsedit

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

Conditional statementsedit

If / Elseedit

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

Loop statementsedit

Foredit

Painless also supports the for in syntax from Groovy:

for (item : list) {
  ...
}