The mapping is epoch_millis
and Kibana is generating query range parameters in epoch_millis
so everything seems fine there.
In elastic datetime field value as YYYY-MM-DD[T]HH:mm:ss.SSS[Z]
Whatever format was used when in the JSON that you used to index the data, as long as Elasticsearch understands those values as dates, then using date ranges in milliseconds format in the query is totally fine.
Here's an example of how Elasticsearch can handle dates given with different formats and match it in queries where the range parameters are epoch_millis (I ran all this in Dev Tools Console):
Create a type:
PUT test
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
}
}
PUT test/type/_mapping
{
"properties": {
"date_of_test": {
"type": "date",
"format": "date_optional_time||epoch_millis"
},
"message": {
"type": "text"
}
}
}
Add some documents using different date formats:
POST test/type/1
{
"date_of_test": "1483722369341",
"message": "Test the first, using epoch_millis format"
}
POST test/type/2
{
"date_of_test": "2017-01-06T17:07:51.041Z",
"message": "Test the second, using ISO format"
}
POST test/type/3
{
"message": "Test the third, no date here"
}
Make a query using a date range aggregation:
POST test/type/_search
{
"size": 0,
"aggs": {
"results": {
"date_range": {
"field": "date_of_test",
"ranges": [
{
"from": "1325777620838",
"to": "2018-01-01T00:00:00.000Z"
}
]
}
}
}
}
Elasticsearch responds with the correct doc_count in the aggregation result:
"aggregations": {
"results": {
"buckets": [
{
"key": "2012-01-05T15:33:40.838Z-2018-01-01T00:00:00.000Z",
"from": 1325777620838,
"from_as_string": "2012-01-05T15:33:40.838Z",
"to": 1514764800000,
"to_as_string": "2018-01-01T00:00:00.000Z",
"doc_count": 2
}
]
}
}
So as I showed, there's no problem with Kibana generating time as epoch_millis for the query.
Can you check in a conversion tool such as https://currentmillis.com/ to make sure you actually have data with DateOfImport
values in the range of 1325777620838 - 1483630420838?
If your data checks out okay, can you provide more information about what type of visualization you are trying to create, and what your metrics and buckets look like, and how you are constructing the date range aggregation?