Can someone help me with the following?
I have a timestamp like this, and want to create it in Elasticsearch in a datefield.
Apr 25, 2019 12:21:19,783 AM CEST
I keep getting errors with unrecognized date format and tried many formats.
The 783 in this case are milliseconds.
Steps that I tried with the following:
PUT _template/template_testindex
{
"index_patterns": ["testindex"],
"settings": {
"number_of_shards": 1
},
"mappings" : {
"doc" : {
"properties" : {
"timestamp" : {
"type" : "date",
"format": "MMM d, yyyy K:m:s,S a z"
}
}
}
}
}
PUT testindex/_doc/1
{
"timestamp": "Apr 25, 2019 12:21:19,783 AM CEST"
}
spinscale
(Alexander Reelsen)
April 25, 2019, 2:44pm
2
Hey Peter,
Try
DELETE foo
PUT foo
{
"mappings": {
"properties": {
"date": {
"type": "date",
"format": "MMM dd, yyyy HH:mm:ss,SSS a z"
}
}
}
}
PUT foo/_doc/1?refresh
{
"date": "Apr 25, 2019 12:21:19,783 PM CEST"
}
GET foo/_search
{
"query": {
"range": {
"date": {
"gte": "2019-04-25",
"format": "strict_date_optional_time"
}
}
}
}
Note, I don't think your AM date in combination with 12:something
is valid.
Note 2, tested under Elasticsearch 7.0.
Hope this helps!
--Alex
Thanks Alexander. I will try this in a bit. Will try it with the real data. I created this string online with a pattern generator.
The production data will be oke I assume at this time.
system
(system)
Closed
May 24, 2019, 6:40am
4
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.