# Date\_detection not working with not\_analyzed fields

**URL:** <https://discuss.elastic.co/t/date-detection-not-working-with-not-analyzed-fields/43758>\
**Category:** Elasticsearch\
**Created:** [March 8, 2016, 11:00am UTC](https://discuss.elastic.co/t/date-detection-not-working-with-not-analyzed-fields/43758 "2016-03-08T11:00:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![palmerabollo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/palmerabollo/32/44772_2.png) [@palmerabollo](https://discuss.elastic.co/u/palmerabollo)\
**Post date:** [March 8, 2016, 11:00am UTC](https://discuss.elastic.co/t/date-detection-not-working-with-not-analyzed-fields/43758/1 "2016-03-08T11:00:08Z")

</div>

I want to enable date\_detection but, at the same time, I want to store all fields as not\_analyzed by default.

So I'm using these mappings with date\_detection: true and a dynamic\_template. Dates are not detected, and they are indexed as strings. If I remove the index: "not\_analyzed" part of the dynamic template, then dates are detected but all my fields are analyzed. Is there any **way to enable both behaviours (date\_detection + not\_analyzed)**?

```
 {
   "template":"*",
   "mappings":{
     "_default_":{
       "date_detection":true,
       "_all":{
         "enabled":false
       },
       "dynamic_templates": [
         {
           "template_do_not_analyze": {
             "mapping": {
               "index": "not_analyzed",
               "type": "{dynamic_type}"
             },
             "match": "*"
           }
         }
       ],
       "properties":{
         "msg":{
           "type":"string",
           "index":"analyzed"
         }
       }
       ...

```

I'm using ElasticSearch 2.2 and I don't know the names of the fields that contain dates in advance.  
Thank you !

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [March 8, 2016, 1:39pm UTC](https://discuss.elastic.co/t/date-detection-not-working-with-not-analyzed-fields/43758/2 "2016-03-08T13:39:23Z")

</div>

I could reproduce the issue indeed. Would you mind opening a bug at [https://github.com/elastic/elasticsearch](https://github.com/elastic/elasticsearch) that paints to this discussion?

---

<div class="post-metadata">

**Author:** ![palmerabollo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/palmerabollo/32/44772_2.png) [@palmerabollo](https://discuss.elastic.co/u/palmerabollo)\
**Post date:** [March 8, 2016, 5:07pm UTC](https://discuss.elastic.co/t/date-detection-not-working-with-not-analyzed-fields/43758/3 "2016-03-08T17:07:04Z")

</div>

Done [https://github.com/elastic/elasticsearch/issues/17012](https://github.com/elastic/elasticsearch/issues/17012)

---

<div class="post-metadata">

**Author:** ![palmerabollo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/palmerabollo/32/44772_2.png) [@palmerabollo](https://discuss.elastic.co/u/palmerabollo)\
**Post date:** [March 8, 2016, 8:03pm UTC](https://discuss.elastic.co/t/date-detection-not-working-with-not-analyzed-fields/43758/4 "2016-03-08T20:03:02Z")

</div>

Someone said there is a workaround. See the issue in github.

---

<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 5, 2017, 11:10pm UTC](https://discuss.elastic.co/t/date-detection-not-working-with-not-analyzed-fields/43758/5 "2017-07-05T23:10:09Z")

</div>


