# Discover: failed to parse date field

**URL:** <https://discuss.elastic.co/t/discover-failed-to-parse-date-field/100932>\
**Category:** Kibana\
**Created:** [September 18, 2017, 8:47pm UTC](https://discuss.elastic.co/t/discover-failed-to-parse-date-field/100932 "2017-09-18T20:47:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suny/32/22082_2.png) [@Suny](https://discuss.elastic.co/u/Suny)\
**Post date:** [September 18, 2017, 8:47pm UTC](https://discuss.elastic.co/t/discover-failed-to-parse-date-field/100932/1 "2017-09-18T20:47:58Z")

</div>

I define in the mapping:

```
        "time" : {
           "type" : "date",
           "format" : "yyyy'M'MM"
        },

```

The field is a date, I can create time histograms. Things look fine in the visualizations, and I can also filter on date. The filter is:

```
 { "range": { "time": { "format": "epoch_millis", "gte": 1470002400000, "lt": 1472680800000 } } } 

```

In the Discover section, this json also works. However, this lucene syntax throws an error:

time : [1470002400000 TO 1472680800000]

This lucene query works fine on indexes with a standard time format.  
The issue is not a problem for me, because json works, but still looks like a bug in the Discover section to me. The error is:

```
Error: Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"parse_exception","reason":"failed to parse date field [1470002400000] with format [yyyy'M'MM]"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"asylum_appl_monthly_","node":"XKPlioC4RVevWytyI-aGyQ","reason":{"type":"query_shard_exception","reason":"failed to create query: {\n \"query_string\" : {\n \"query\" : \"time : [1470002400000 TO 1472680800000]\",\n \"fields\" : [],\n \"use_dis_max\" : true,\n \"tie_breaker\" : 0.0,\n \"default_operator\" : \"or\",\n \"auto_generate_phrase_queries\" : false,\n \"max_determinized_states\" : 10000,\n \"enable_position_increments\" : true,\n \"fuzziness\" : \"AUTO\",\n \"fuzzy_prefix_length\" : 0,\n \"fuzzy_max_expansions\" : 50,\n \"phrase_slop\" : 0,\n \"analyze_wildcard\" : true,\n \"escape\" : false,\n \"split_on_whitespace\" : true,\n \"boost\" : 1.0\n }\n}","index_uuid":"w-LU7xwkTzmJyzekFUUPIg","index":"asylum_appl_monthly_","caused_by":{"type":"parse_exception","reason":"failed to parse date field [1470002400000] with format [yyyy'M'MM]","caused_by":{"type":"illegal_argument_exception","reason":"Parse failure at index [9] of [1470002400000]"}}}}]},"status":400}
KbnError@https://31ddbfabcd679aee43b4b24bd2a6f8c4.eu-west-1.aws.found.io:9243/bundles/commons.bundle.js?v=15523:92:13722
RequestFailure@https://31ddbfabcd679aee43b4b24bd2a6f8c4.eu-west-1.aws.found.io:9243/bundles/commons.bundle.js?v=15523:92:14531
https://31ddbfabcd679aee43b4b24bd2a6f8c4.eu-west-1.aws.found.io:9243/bundles/kibana.bundle.js?v=15523:229:30408
https://31ddbfabcd679aee43b4b24bd2a6f8c4.eu-west-1.aws.found.io:9243/bundles/commons.bundle.js?v=15523:91:17547
map@[native code]
map@https://31ddbfabcd679aee43b4b24bd2a6f8c4.eu-west-1.aws.found.io:9243/bundles/commons.bundle.js?v=15523:91:16870
processQueue@https://31ddbfabcd679aee43b4b24bd2a6f8c4.eu-west-1.aws.found.io:9243/bundles/commons.bundle.js?v=15523:38:23623
https://31ddbfabcd679aee43b4b24bd2a6f8c4.eu-west-1.aws.found.io:9243/bundles/commons.bundle.js?v=15523:38:23900
$digest@https://31ddbfabcd679aee43b4b24bd2a6f8c4.eu-west-1.aws.found.io:9243/bundles/commons.bundle.js?v=15523:39:2364
$apply@https://31ddbfabcd679aee43b4b24bd2a6f8c4.eu-west-1.aws.found.io:9243/bundles/commons.bundle.js?v=15523:39:5044
done@https://31ddbfabcd679aee43b4b24bd2a6f8c4.eu-west-1.aws.found.io:9243/bundles/commons.bundle.js?v=15523:37:25033
completeRequest@https://31ddbfabcd679aee43b4b24bd2a6f8c4.eu-west-1.aws.found.io:9243/bundles/commons.bundle.js?v=15523:37:28710
onload@https://31ddbfabcd679aee43b4b24bd2a6f8c4.eu-west-1.aws.found.io:9243/bundles/commons.bundle.js?v=15523:37:29649
```

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [September 18, 2017, 11:11pm UTC](https://discuss.elastic.co/t/discover-failed-to-parse-date-field/100932/2 "2017-09-18T23:11:41Z")

</div>

I create a mapping like this;

```auto
PUT test6
{
   "mappings": {
     "test": {
       "properties": {
        "time" : {
           "type" : "date",
           "format" : "yyyy'M'MM"
        }
       }
     }
   }
 }

```

And created a few docs like this one;

```auto
POST test6/test
{
  "time":"2017M06",
  "value":"jun17"
}

```

I can seem them in Discover;

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/6/b67a28810c37d10b16d9af254069637c4ef080fc.png)

And I was able to add a filter in Discover using the same date format used to post the docs;

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/a/4ad425d042a9add12418b16b51c5e8e70483903d.png)

And if I edit the DSL Query, I see the same format;

```auto
{
  "range": {
    "time": {
      "gte": "2017M07",
      "lt": "2017M09"
    }
  }
}

```

And I can also put this in the query bar `time:["2017M08" TO "2017M09"]`

So far, so good. But if I click on the + by a time value to add a filter I get this;

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/6/56e3518fb2cdf3a0c2cc2e232fcc27049eb66e3b.png)

And the query for that is;

```auto
{
  "query": {
    "match": {
      "time": {
        "query": 1501545600000,
        "type": "phrase"
      }
    }
  }
}

```

So I thought I would set the format for this `time` field in the index pattern to "YYYY'M'MM" so that it would show correctly in Discover, and might also fix this issue. But it's not treating the single-quoted 'M' as a string. I'll file a bug on that.

> <https://github.com/elastic/kibana/issues/14049>

---

<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:** [October 16, 2017, 11:11pm UTC](https://discuss.elastic.co/t/discover-failed-to-parse-date-field/100932/3 "2017-10-16T23:11:48Z")

</div>

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