Indexof and substring on custom field on kibana version 5.6

I am currently using kibana version 5.6.

I would like to

  1. search the position of string in a field and then
  2. extract the substring from the field
  3. show to value on "Discover"

Code Example:

def x = doc["description"].value
if (x != null) {
int pos = x.indexof("start")
if (pos > 0) {
return x.substring(pos, 20)
return "not found"

currently, pos is alway 0.

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