# I have hypen separated in one column and i want to use that column in elastic search. Mapping created with type. Need to escape the hypen and get the whole value

**URL:** https://discuss.elastic.co/t/i-have-hypen-separated-in-one-column-and-i-want-to-use-that-column-in-elastic-search-mapping-created-with-type-need-to-escape-the-hypen-and-get-the-whole-value/266998
**Category:** Kibana
**Tags:** ecs-elastic-common-schema
**Created:** [March 11, 2021, 8:39pm UTC](https://discuss.elastic.co/t/i-have-hypen-separated-in-one-column-and-i-want-to-use-that-column-in-elastic-search-mapping-created-with-type-need-to-escape-the-hypen-and-get-the-whole-value/266998 "2021-03-11T20:39:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Sreenath\_G](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sreenath_g/32/85415_2.png) [@Sreenath\_G](https://discuss.elastic.co/u/Sreenath_G)
#### Post date: [March 11, 2021, 8:39pm UTC](https://discuss.elastic.co/t/i-have-hypen-separated-in-one-column-and-i-want-to-use-that-column-in-elastic-search-mapping-created-with-type-need-to-escape-the-hypen-and-get-the-whole-value/266998/1 "2021-03-11T20:39:29Z")

</div>

Below is mapping:  
"TestID" : {  
"type" : "text",  
"fielddata" : true

Example value of ID is "12333-1arerd-2333d-rrrrrwwqq"

In the scripted field of the Index pattern i have given the below Script:  
if (doc['TestID'] == null || doc['TestID'].isEmpty())  
{  
return "";  
}  
String res = doc['TestID'][0];  
return res;

After created index and Inserted data, i could get only the part of the ID.

"TestID": [  
"2333d"]

How to escape this hypen and pass the whole id value. Due to token i am getting it in terms.

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [March 12, 2021, 1:50am UTC](https://discuss.elastic.co/t/i-have-hypen-separated-in-one-column-and-i-want-to-use-that-column-in-elastic-search-mapping-created-with-type-need-to-escape-the-hypen-and-get-the-whole-value/266998/2 "2021-03-12T01:50:50Z")

</div>

Hi @Sreenath_G Welcome to the community.

Have you thought about just creating a multi-type field

```
"TestID" : {
  "type" : "text",
  "fields" : {
    "keyword" : {
      "type" : "keyword",
      "ignore_above" : 256
    }
  }
}

```

The to get the whole field you would just access the `TestID.keyword` field which would have the whole string untokenized, that way you could do text search and still have the whole unaltered string.

---

<div class="post-metadata">

### Author: ![Sreenath\_G](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sreenath_g/32/85415_2.png) [@Sreenath\_G](https://discuss.elastic.co/u/Sreenath_G)
#### Post date: [March 15, 2021, 1:28pm UTC](https://discuss.elastic.co/t/i-have-hypen-separated-in-one-column-and-i-want-to-use-that-column-in-elastic-search-mapping-created-with-type-need-to-escape-the-hypen-and-get-the-whole-value/266998/3 "2021-03-15T13:28:37Z")

</div>

> [@stephenb](#):
>
> `keyword`

Thanks for your reply and time.  
Could you please let me know if there is any possiblity for getting the untokenzied value of the ID without changing the mapping from Text to Keyword.  
As mentioned earlier, below is the script which i have tried in the Scriptted field:

if (doc['TestID'] == null || doc['TestID'].isEmpty()) {  
return "";  
}  
String res = doc['TestID'][0];  
return res;

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [March 15, 2021, 2:15pm UTC](https://discuss.elastic.co/t/i-have-hypen-separated-in-one-column-and-i-want-to-use-that-column-in-elastic-search-mapping-created-with-type-need-to-escape-the-hypen-and-get-the-whole-value/266998/4 "2021-03-15T14:15:03Z")

</div>

I am not a scripting expert but the original string should still be in the `_source` I would look how to access that.

---

<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: [April 12, 2021, 2:15pm UTC](https://discuss.elastic.co/t/i-have-hypen-separated-in-one-column-and-i-want-to-use-that-column-in-elastic-search-mapping-created-with-type-need-to-escape-the-hypen-and-get-the-whole-value/266998/5 "2021-04-12T14:15:46Z")

</div>

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