Truncate part of a value of a string field in Kibana?

I'm having a field called userid (analyzed and the datatype is text) and all it's value pretend to be as follows:

sometext@something.super
newtext@something.super

So what I need is, to trim the above value so that I can only get the text in front of @something.super.

I tried writing a painless script in order to check whether the value contains the @something.super, if so then assign the value to an empty string but still no luck.

Is trimming possible for a string field in Kibana? Or

Is it possible to trim the value in elasticsearch itself if I'm to update the existing field?

Any help could be appreciated.

You could probably use a custom analyzer with a pattern tokenizer to accomplish what you are looking for:

custom analyzer: https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-custom-analyzer.html
pattern tokenizer: https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-pattern-tokenizer.html

1 Like

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