0

I create an index in ES7.8 with date format "yyyy-MM-dd"

"mappings": {
    "_doc": {
      "properties": {
        "BaseLine": {
          "type": "date",
          "format": "yyyy-MM-dd"
        },

However, when I click the "Baseline" field on the map, the actual value passed on Filter is yyyy-MM-dd00:00:00.000Z.

Can anyone advise how can I get the correct date format "yyyy-MM-dd" in the filter?

Thanks.

enter image description here

Here is the sample document from a request

"hits" : [ { "_index" : "program_b", "_type" : "_doc", "_id" : "2137SD19.1", "_score" : 0.0, "_source" : { "SiteID" : 2137, "BaseLine" : "2020-04-26", "uk" : "2137SD19.1" } },

2
  • Can you show a sample document that you have indexed. Ideally the one you clicked on on the map Commented Aug 11, 2020 at 6:02
  • @Val I have edited the post with a response in Dev tool. Hope that works. The original documents are in .csv format Commented Aug 11, 2020 at 7:11

1 Answer 1

2

The role of the "format": "yyyy-MM-dd" in your mapping is only to tell ES in which format your date values will be present in your source document.

As you can see, your source document contains "BaseLine" : "2020-04-26" which is exactly in the format that you've instructed ES to expect. When you index your document, ES will properly parse your BaseLine date field and index a long value representing that point in time.

The value you see in the tooltip (i.e. Apr 26, 2020) is just how Kibana formats your dates, you can change that in "Stack Management > Advanced settings" if needed.

Finally, the filter value you see in your filter (i.e. 2020-04-26T00:00:00.000Z) is the ISO8601 representation of your BaseLine field and what ES use in the query filter.

Everything looks perfectly correct as far as I can tell.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for your feedback. But the problem is when I click the "Baseline" filed from the map, the Timelion Chart of the same Dashboard will report this error: [parse_exception] failed to parse date field [2020-04-26T00:00:00.000Z] with format [yyyy-MM-dd]: [failed to parse date field [2020-04-26T00:00:00.000Z] with format [yyyy-MM-dd]]
Well, you didn't mention Timelion in your initial question :-) Can you tell a bit more how your Timelion expression looks like?
What you can do, is to change the format to date_optional_time instead of yyyy-MM-dd so both 2020-04-26 and 2020-04-26T00:00:00.000Z would be allowed
Yes, the error is gone after I change the format to "date_optional_time". Thanks, headps~

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.