# Not\_analyzed as default for string type for multiple indices

**URL:** <https://discuss.elastic.co/t/not-analyzed-as-default-for-string-type-for-multiple-indices/20276>\
**Category:** Elasticsearch\
**Created:** [October 16, 2014, 8:34am UTC](https://discuss.elastic.co/t/not-analyzed-as-default-for-string-type-for-multiple-indices/20276 "2014-10-16T08:34:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gargoyle\_2](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@Gargoyle\_2](https://discuss.elastic.co/u/Gargoyle_2)\
**Post date:** [October 16, 2014, 8:34am UTC](https://discuss.elastic.co/t/not-analyzed-as-default-for-string-type-for-multiple-indices/20276/1 "2014-10-16T08:34:19Z")

</div>

Hi,

I collect performance data into ES and my indices are named in a form  
"prefix\_" in order to delete old data efficiently. For all  
those indices and all types within them, I'd like to have string fields  
not\_analyzed and exact matched in searches. My issue is that indices are  
created by first index request to them, so I cannot easily preset the  
analyzers via mappers. I've tried to use global templates as:

POST [http://localhost:9200/\_template/t2](http://localhost:9200/_template/t2)

{  
"template" : "z\*",  
"mapping" : {  
"type" : "string",  
"index" : "not\_analyzed"  
}  
}

which seems to be taken into consideration when the index is created, but  
still, for filtered query like:

{  
"query": {  
"filtered" : {  
"filter" : {  
"bool" : {  
"must" : [  
{"term" : {"path4" : "BASE"}},  
{"term" : {"path3" : "vm-609"}}  
]  
}  
}  
}  
}  
}

I'm not getting any document while for query\_string query like:  
{  
"query" : {  
"query\_string" : {  
"query" : "path3:"vm-609" AND path4:"BASE""  
}  
}  
}

I'm getting the expected results.

So my question is, how to disable string field analysis in order to be able  
to use filtered queries for all in future created indices whose names  
follow my pattern "prefix\_"

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0ae751d3-fc67-42a1-8130-d8116398b7ed%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0ae751d3-fc67-42a1-8130-d8116398b7ed%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Gargoyle\_2](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@Gargoyle\_2](https://discuss.elastic.co/u/Gargoyle_2)\
**Post date:** [October 16, 2014, 3:48pm UTC](https://discuss.elastic.co/t/not-analyzed-as-default-for-string-type-for-multiple-indices/20276/2 "2014-10-16T15:48:40Z")

</div>

> This did the trick for me:

POST [http://localhost:9200/\_template/t2](http://localhost:9200/_template/t2)

{  
"template" : "z\*",  
"mappings" : {  
"_default_" : {  
"\_all" : {"enabled" : false},  
"dynamic\_templates": [  
{ "string\_match": {  
"match": "\*",  
"match\_mapping\_type": "string",  
"mapping": {  
"type": "string",  
"index" : "not\_analyzed"  
}  
}}  
]

```
    }
}

```

}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b9a01536-c028-4402-b86a-c38dcec09fd8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b9a01536-c028-4402-b86a-c38dcec09fd8%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 12:55am UTC](https://discuss.elastic.co/t/not-analyzed-as-default-for-string-type-for-multiple-indices/20276/3 "2017-07-06T00:55:45Z")

</div>


