Scripted field to count occurence in string does not work

Hi, I am trying to create a scripted field on Kibana for counting the number occurrences of slash ('/') character inside a string field like so:
doc['my_field.keyword']?.value?.count('/')
But 'discover' page throws me 'Courier Fetch: 5 of 15 shards failed.' and is not able to show any data (No result found).

I have another scripted field that is just for counting the length of that same field like so:
doc['my_field.keyword']?.value?.length()
And it works fine. Which means there is nothing wrong with that field but perhaps the 'count' method is not supported in scripted field?

There is no such thing as a count method. You need to implement this count using your own algorithm.

Painless is limited to what Java can provide in terms of API.

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