Date_detection not working with not_analyzed fields


(Guido) #1

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 !


(Adrien Grand) #2

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


(Guido) #3

Done https://github.com/elastic/elasticsearch/issues/17012


(Guido) #4

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


(system) #5