Painless 支持所有 Java 的 控制流语句,除了 switch
语句。
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 也支持 for in
语法。
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)