Arrays indexes starts at -1 with painless on Kibana v7.4.0

I'm using kibana v7.4.0 deployed via

I was trying to create a scripted field to match a specific field with a regex.
The field I'm working with in an analyzed string field containing a process' arguments :

def processArgs = doc['process.args']; 

if contans something like :

  "_id": "DBYUvm0BRrdyTjK0i_EP",
  "process": {
   "args": [

However in my script, when I try to access the first value of the array I would normally do :


Except it doesn't work ! It returns the value of the second element of the array !

After some painful testing, the painless interpreter seems to interpret array indexing as :

doc['process.args'][-2] -> last
doc['process.args'][-1] -> 1stelement
doc['process.args'][0] -> 2nd element
doc['process.args'][1] -> 3rd element
doc['process.args'][doc['process.args'].length - 2] -> last element
etc ..

And it loops around the (end - 2) index of the array.

What witchery is that ?!

could you please open an issue as this is a bug not a question.


Ok, here it is :

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.