I'm having an issue when I try to retrieve information from elasticsearch.
when i do a simple query :
var searchResponse = client.Search<injectedData>(s => s.MatchAll());
I catch an invalid datetime format. value:2020-01-07 11:46:44
as error
What I don't understand is that I specify the exact format when I serialize DateTime
public class MyDateTimeConverter : IsoDateTimeConverter
{
public MyDateTimeConverter()
{
DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
}
}
class injectedData
{
public String Id { get; set; }
[JsonConverter(typeof(MyDateTimeConverter))]
public DateTime process_start_time { get; set; }
[JsonConverter(typeof(MyDateTimeConverter))]
public DateTime item_start_time { get; set; }
[JsonConverter(typeof(MyDateTimeConverter))]
public DateTime item_end_time { get; set; }
[JsonConverter(typeof(MyDateTimeConverter))]
public DateTime end_time { get; set; }
public long process_execution_duration { get; set; }
public int metadata_type { get; set; }
public String machine { get; set; }
public String windows_session { get; set; }
public String proces_name { get; set; }
public String item { get; set; }
}
The mapping looks like this
{
"properties": {
"process_start_time": {
"type": "date",
"format":"yyyy-MM-dd HH:mm:ss"
},
"item_start_time": {
"type": "date",
"format":"yyyy-MM-dd HH:mm:ss"
},
"item_end_time": {
"type":"date",
"format":"yyyy-MM-dd HH:mm:ss"
},
"end_time": {
"type":"date",
"format":"yyyy-MM-dd HH:mm:ss"
}
}
}
I can't seem to understand where the issue is coming from. Does someone have an idea?
update 14: 01: 2020
So it seems, that if I insert data without a mapping in the base time format yyyyDDD'T'HHmmss.SSSZ "Like this "2019-07-04T05:53:00,544" I don't have any issues.
Can't I work with custom date format if I use nest?
So I don't know why I couldn't work with custom dateFormat but I've changed the format to the time basic format everywhere and it works now. I still don't get why it didn't work the way I did previously but I guess you can't or I missed something somewhere.