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

**URL:** https://discuss.elastic.co/t/truncate-part-of-a-value-of-a-string-field-in-kibana/71705
**Category:** Kibana
**Created:** [January 16, 2017, 9:41am UTC](https://discuss.elastic.co/t/truncate-part-of-a-value-of-a-string-field-in-kibana/71705 "2017-01-16T09:41:21Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Kulasangar\_Gowrisang](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@Kulasangar\_Gowrisang](https://discuss.elastic.co/u/Kulasangar_Gowrisang)
#### Post date: [January 16, 2017, 9:41am UTC](https://discuss.elastic.co/t/truncate-part-of-a-value-of-a-string-field-in-kibana/71705/1 "2017-01-16T09:41:21Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![spalger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spalger/32/14092_2.png) [@spalger](https://discuss.elastic.co/u/spalger)
#### Post date: [January 16, 2017, 11:54pm UTC](https://discuss.elastic.co/t/truncate-part-of-a-value-of-a-string-field-in-kibana/71705/2 "2017-01-16T23:54:38Z")

</div>

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](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](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-pattern-tokenizer.html)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [February 13, 2017, 11:54pm UTC](https://discuss.elastic.co/t/truncate-part-of-a-value-of-a-string-field-in-kibana/71705/3 "2017-02-13T23:54:37Z")

</div>

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