# How to make String Field to Non Analyzed?

**URL:** <https://discuss.elastic.co/t/how-to-make-string-field-to-non-analyzed/79809>\
**Category:** Elasticsearch\
**Created:** [March 23, 2017, 8:16pm UTC](https://discuss.elastic.co/t/how-to-make-string-field-to-non-analyzed/79809 "2017-03-23T20:16:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![venkat\_venkat](https://avatars.discourse-cdn.com/v4/letter/v/f17d59/32.png) [@venkat\_venkat](https://discuss.elastic.co/u/venkat_venkat)\
**Post date:** [March 23, 2017, 8:16pm UTC](https://discuss.elastic.co/t/how-to-make-string-field-to-non-analyzed/79809/1 "2017-03-23T20:16:57Z")

</div>

I am trying to Make String Field Analyzed to non-analyzed. But I am unable to make the string field the non-analyzed. My String field Hostname look like "q-gp2-qadebug-1". Please help me out how to make it non-analyzed.  
I am using Elasticsearch 5.2.2

 ![](https://us1.discourse-cdn.com/elastic/original/3X/5/c/5c9b113f8db49304da8348fca537db50cb3ff142.png)

Please find the below template, I am using.

curl -XPUT '[http://localhost:9200/\_template/elasticsearchstats](http://localhost:9200/_template/elasticsearchstats)' -d '{  
"template": "elasticsearchstats",  
"order": 10,  
"settings": {  
"index.refresh\_interval": "5s"  
},  
"mappings": {  
"default": {  
"\_all": {  
"enabled": true,  
"omit\_norms": true  
},  
"dynamic\_templates": [  
{  
"string\_fields": {  
"match": "_",  
"match\_mapping\_type": "string",  
"mapping": {  
"type": "keyword"  
}  
}  
},  
{  
"float\_fields": {  
"match": "_",  
"match\_mapping\_type": "float",  
"mapping": {  
"type": "float",  
"doc\_values": true  
}  
}  
},  
{  
"double\_fields": {  
"match": "_",  
"match\_mapping\_type": "double",  
"mapping": {  
"type": "double",  
"doc\_values": true  
}  
}  
},  
{  
"byte\_fields": {  
"match": "_",  
"match\_mapping\_type": "byte",  
"mapping": {  
"type": "byte",  
"doc\_values": true  
}  
}  
},  
{  
"short\_fields": {  
"match": "_",  
"match\_mapping\_type": "short",  
"mapping": {  
"type": "short",  
"doc\_values": true  
}  
}  
},  
{  
"integer\_fields": {  
"match": "_",  
"match\_mapping\_type": "integer",  
"mapping": {  
"type": "integer",  
"doc\_values": true  
}  
}  
},  
{  
"long\_fields": {  
"match": "_",  
"match\_mapping\_type": "long",  
"mapping": {  
"type": "long",  
"doc\_values": true  
}  
}  
},  
{  
"date\_fields": {  
"match": "_",  
"match\_mapping\_type": "date",  
"mapping": {  
"type": "date",  
"doc\_values": true  
}  
}  
},  
{  
"geo\_point\_fields": {  
"match": "\*",  
"match\_mapping\_type": "geo\_point",  
"mapping": {  
"type": "geo\_point",  
"doc\_values": true  
}  
}  
}  
],  
"properties": {  
"@timestamp": {  
"type": "date",  
"doc\_values": true  
},  
"@version": {  
"type": "string",  
"index": "not\_analyzed",  
"doc\_values": true  
},  
"clusterstatus" : {  
"type" : "long"  
},  
"cpupercent" : {  
"type" : "long"  
},  
"fielddataestimated" : {  
"type" : "long"  
},  
"fielddatalimit" : {  
"type" : "long"  
},  
"freedisk" : {  
"type" : "long"  
},  
"currentstatus" : {  
"type" : "string",  
"index" : "not\_analyzed"  
},  
"hostname" : {  
"type": "keyword",  
"index" : "no"  
},  
"testname" : {  
"type": "keyword"  
},  
"freemem" : {  
"type" : "long"  
},  
"heapold" : {  
"type" : "long"  
},  
"heapsurvior" : {  
"type" : "long"  
},  
"heapused" : {  
"type" : "long"  
},  
"heapyoung" : {  
"type" : "long"  
},  
"loadaverage" : {  
"type" : "long"  
},  
"hostname" : {  
"type" : "string"  
},  
"openfiles" : {  
"type" : "float"  
},  
"threadcount" : {  
"type" : "float"  
},  
"type" : {  
"type" : "string"  
},  
"geoip": {  
"type": "object",  
"dynamic": true,  
"properties": {  
"ip": {  
"type": "ip",  
"doc\_values": true  
},  
"location": {  
"type": "geo\_point",  
"doc\_values": true  
},  
"latitude": {  
"type": "float",  
"doc\_values": true  
},  
"longitude": {  
"type": "float",  
"doc\_values": true  
}  
}  
}  
}  
}  
}  
}'

---

<div class="post-metadata">

**Author:** ![venkat\_venkat](https://avatars.discourse-cdn.com/v4/letter/v/f17d59/32.png) [@venkat\_venkat](https://discuss.elastic.co/u/venkat_venkat)\
**Post date:** [March 23, 2017, 8:32pm UTC](https://discuss.elastic.co/t/how-to-make-string-field-to-non-analyzed/79809/2 "2017-03-23T20:32:52Z")

</div>

I am also tried to use string field as .raw in the below template, but the same result.

curl -XPUT '[http://localhost:9200/\_template/elasticsearchstats](http://localhost:9200/_template/elasticsearchstats)' -d '{

> ```
> "template": "elasticsearchstats",
> "order": 10,
> "settings": {
> "index.refresh_interval": "5s"
> },
> "mappings": {
> "_default_": {
> "_all": {
> "enabled": true,
> "omit_norms": true
> },
> "dynamic_templates": [
> {
> "string_fields": {
> "match": "*",
> "match_mapping_type": "string",
> "mapping": {
> "type": "keyword"
> }
> }
> },
> {
> "float_fields": {
> "match": "*",
> "match_mapping_type": "float",
> "mapping": {
> "type": "float",
> "doc_values": true
> }
> }
> },
> {
> "double_fields": {
> "match": "*",
> "match_mapping_type": "double",
> "mapping": {
> "type": "double",
> "doc_values": true
> }
> }
> },
> {
> "byte_fields": {
> "match": "*",
> "match_mapping_type": "byte",
> "mapping": {
> "type": "byte",
> "doc_values": true
> }
> }
> },
> {
> "short_fields": {
> "match": "*",
> "match_mapping_type": "short",
> "mapping": {
> "type": "short",
> "doc_values": true
> }
> }
> },
> {
> "integer_fields": {
> "match": "*",
> "match_mapping_type": "integer",
> "mapping": {
> "type": "integer",
> "doc_values": true
> }
> }
> },
> {
> "long_fields": {
> "match": "*",
> "match_mapping_type": "long",
> "mapping": {
> "type": "long",
> "doc_values": true
> }
> }
> },
> {
> "date_fields": {
> "match": "*",
> "match_mapping_type": "date",
> "mapping": {
> "type": "date",
> "doc_values": true
> }
> }
> },
> {
> "geo_point_fields": {
> "match": "*",
> "match_mapping_type": "geo_point",
> "mapping": {
> "type": "geo_point",
> "doc_values": true
> }
> }
> }
> ],
> "properties": {
> "@timestamp": {
> "type": "date",
> "doc_values": true
> },
> "@version": {
> "type": "string",
> "index": "not_analyzed",
> "doc_values": true
> },
> "clusterstatus" : {
> "type" : "long"
> },
> "cpupercent" : {
> "type" : "long"
> },
> "fielddataestimated" : {
> "type" : "long"
> },
> "fielddatalimit" : {
> "type" : "long"
> },
> "freedisk" : {
> "type" : "long"
> },
> "currentstatus" : {
> "type" : "text",
> "fields": {
> "raw": {
> "type": "keyword"
> }
> }
> },
> "hostname" : {
> "type": "text",
> "fields": {
> "raw": {
> "type": "keyword"
> }
> }
> },
> "testname" : {
> "type": "keyword"
> },
> "freemem" : {
> "type" : "long"
> },
> "heapold" : {
> "type" : "long"
> },
> "heapsurvior" : {
> "type" : "long"
> },
> "heapused" : {
> "type" : "long"
> },
> "heapyoung" : {
> "type" : "long"
> },
> "loadaverage" : {
> "type" : "long"
> },
> "hostname" : {
> "type" : "string"
> },
> "openfiles" : {
> "type" : "float"
> },
> "threadcount" : {
> "type" : "float"
> },
> "type" : {
> "type" : "string"
> },
> "geoip": {
> "type": "object",
> "dynamic": true,
> "properties": {
> "ip": {
> "type": "ip",
> "doc_values": true
> },
> "location": {
> "type": "geo_point",
> "doc_values": true
> },
> "latitude": {
> "type": "float",
> "doc_values": true
> },
> "longitude": {
> "type": "float",
> "doc_values": true
> }
> }
> }
> }
> }
> }
> 
> ```
> 
> }'

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 23, 2017, 9:02pm UTC](https://discuss.elastic.co/t/how-to-make-string-field-to-non-analyzed/79809/3 "2017-03-23T21:02:13Z")

</div>

Did you delete your index?

What is your actual mapping ?

---

<div class="post-metadata">

**Author:** ![venkat\_venkat](https://avatars.discourse-cdn.com/v4/letter/v/f17d59/32.png) [@venkat\_venkat](https://discuss.elastic.co/u/venkat_venkat)\
**Post date:** [March 23, 2017, 9:14pm UTC](https://discuss.elastic.co/t/how-to-make-string-field-to-non-analyzed/79809/4 "2017-03-23T21:14:23Z")

</div>

yes, I Delete the index.....

My mappings are

"template": "elasticsearchstats",  
"order": 10,  
"settings": {  
"index.refresh\_interval": "5s"  
},  
"mappings": {  
"_default_": {  
"\_all": {  
"enabled": true,  
"omit\_norms": true  
},  
"dynamic\_templates": [  
{  
"string\_fields": {  
"match": "_",  
"match\_mapping\_type": "string",  
"mapping": {  
"type": "keyword"  
}  
}  
},  
{  
"float\_fields": {  
"match": "_",  
"match\_mapping\_type": "float",  
"mapping": {  
"type": "float",  
"doc\_values": true  
}  
}  
},  
{  
"double\_fields": {  
"match": "_",  
"match\_mapping\_type": "double",  
"mapping": {  
"type": "double",  
"doc\_values": true  
}  
}  
},  
{  
"byte\_fields": {  
"match": "_",  
"match\_mapping\_type": "byte",  
"mapping": {  
"type": "byte",  
"doc\_values": true  
}  
}  
},  
{  
"short\_fields": {  
"match": "_",  
"match\_mapping\_type": "short",  
"mapping": {  
"type": "short",  
"doc\_values": true  
}  
}  
},  
{  
"integer\_fields": {  
"match": "_",  
"match\_mapping\_type": "integer",  
"mapping": {  
"type": "integer",  
"doc\_values": true  
}  
}  
},  
{  
"long\_fields": {  
"match": "_",  
"match\_mapping\_type": "long",  
"mapping": {  
"type": "long",  
"doc\_values": true  
}  
}  
},  
{  
"date\_fields": {  
"match": "_",  
"match\_mapping\_type": "date",  
"mapping": {  
"type": "date",  
"doc\_values": true  
}  
}  
},  
{  
"geo\_point\_fields": {  
"match": "\*",  
"match\_mapping\_type": "geo\_point",  
"mapping": {  
"type": "geo\_point",  
"doc\_values": true  
}  
}  
}  
],

---

<div class="post-metadata">

**Author:** ![jaddison](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@jaddison](https://discuss.elastic.co/u/jaddison)\
**Post date:** [March 23, 2017, 10:03pm UTC](https://discuss.elastic.co/t/how-to-make-string-field-to-non-analyzed/79809/5 "2017-03-23T22:03:59Z")

</div>

You have `Hostname` in there twice.

---

<div class="post-metadata">

**Author:** ![venkat\_venkat](https://avatars.discourse-cdn.com/v4/letter/v/f17d59/32.png) [@venkat\_venkat](https://discuss.elastic.co/u/venkat_venkat)\
**Post date:** [March 27, 2017, 5:56pm UTC](https://discuss.elastic.co/t/how-to-make-string-field-to-non-analyzed/79809/6 "2017-03-27T17:56:27Z")

</div>

Thanks. It is working now

---

<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 24, 2017, 5:57pm UTC](https://discuss.elastic.co/t/how-to-make-string-field-to-non-analyzed/79809/7 "2017-04-24T17:57:20Z")

</div>

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