Hello, im use elastic 7.10.1 and i need help
I wanna sort my numbers, but i can't use number type, so i decide sort it with leading zeroes
{
"sort": {
"_script": {
"type": "string",
"order": "asc",
"script": {
"lang": "painless",
"source": "if(doc.containsKey('pid') && params._source.pid instanceof int)\n{ return '000' + doc['pid'].value.toString()}"
}
}
}
}
i want add N leading zeroes, for example:
number = 7, expected: 007
number = 21, expected 021
number = 300, expected 300
decision is
'0' * doc['pid'].size()
but in Java (or/and painless) i can't multiply str with int, any idea?