elasticsearch exception inserted for time type format

Viewed 131

es version: 7.10.1 kibana version: 7.10.0

First, let me show my index mapping

{
"settings": {
    "number_of_shards": 3,
    "number_of_replicas": 1,
    "index.mapping.total_fields.limit": 10000,
    "refresh_interval": "120s"
},
"mappings": {
    "date_detection": false,
    "dynamic_templates": [{
            "integers": {
                "match_mapping_type": "long",
                "mapping": {
                    "type": "keyword"
                }
            }
        },
        {
            "strings": {
                "match_mapping_type": "string",
                "mapping": {
                    "type": "keyword"
                }
            }
        }
    ],
    "properties": {
        "user": {
            "type": "keyword"
        },
        "user_dept_name": {
            "type": "keyword"
        },
        "user_dept_id": {
            "type": "keyword"
        },
        "user_leave_dept_time": {
            "type": "date",
            "format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
        },
        "user_dept_time": {
            "type": "date",
            "format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
        },
        "user_dimission_time": {
            "type": "date",
            "format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
        },
        "user_dimiss_apply_time": {
            "type": "date",
            "format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
        },
        "user_status": {
            "type": "keyword"
        },
        "nested_object": {
            "type": "nested"
        },
        "operation_type": {
            "type": "keyword"
        },
        "message": {
            "type": "text"
        },
        "throw_exception": {
            "type": "text"
        },
        "timestamp": {
            "type": "date",
            "format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
        },
        "time": {
            "type": "date",
            "format": "HH:mm:ss.SSSZ"
        }
    }
}

in kibana, when I try to insert data, sometimes it can be inserted successfully, sometimes it prompts an exception.

exception message

Succeeded this time

I don’t know what the problem is, I hope friends will help me

email: lcxkaka@foxmail.com

1 Answers

In the date format for time field you are using "format": "HH:mm:ss.SSSZ" (note SSS), but while indexing the data ("10:12:08.61+0800") you are only having 2 digits of S.

So either you need to reformat your data as "10:12:08.061+0800", or change the index mapping as shown below -

You need to change your mapping to -

{
  "mappings": {
    "properties": {
      "time": {
        "type": "date",
        "format": "HH:mm:ss.SSZ"     // note this
      }
    }
  }
}
Related