Hello,
I am trying to use painless field script to check if the content of a field has only numeric values, but the script is showing error.
Elasticsearch is set script.painless.regex.enabled: true.
I tried to use it as follows:
if (doc['tamanho.keyword'].size() != 0) {
if (doc['tamanho.keyword'].value ==~ /[0-9]/ ) {
return doc['tamanho.keyword'].value
} else {
return 0
}
} else {
return 0
}
I am getting the following error:
And:
if (doc['tamanho.keyword'].size() != 0) {
def m =/[0-9]/.matcher(doc['tamanho.keyword'].value);
if (m.matches() ) {
return m.group(1)
}else{
return 0
}
}else{
return 0
}
I am getting the following error: