Split data in painless

Hi team

This is part of a watcher that i'm doing, but split part is nor working, this is my example

  String indices = "index1\nindex2\n";
       String[] arr = indices.split('\n');
       
        return arr;

But i get an error spliting the data

Tested in Painless Lab in Kibana.

Parameters

{
  "string_parameter": "index1\nindex2\n"
}

Code

String[] myArray = /\n/.split(params.string_parameter);
return myArray[0];

Output

index1
1 Like

sorry for the delay, it works for me!! thanks!

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