'how to format date elasticsearch
1.my search Query
var searchResults = await client.SearchAsync<CDPDocument>(i => i
.Index(indexname)
.From(0)
.Size(1)
.Query(q => q
.Bool(b => b
.Must(
bs => bs.Exists(p => p.Field("demoinfos"))
)
)
)
);
- my class
public class CDPDocument
{
[Text(Index = true)]
public string phone { get; set; }
[Boolean(Index = true)]
public bool is_active { get; set; }
[Date]
public DateTime updatedate{ get; set; }
}
- invalid datetime format. value:2021-10-23 08:55:37
because elasticsearch data is "updatedate" : "2021-10-21 20:43:46"
this is Exception :
Exception: InvalidOperationException Took: 00:00:00.1149820
Audit exception in step 3 BadResponse:
System.InvalidOperationException: invalid datetime format. value:2021-10-23 08:55:37 at Elasticsearch.Net.Utf8Json.Formatters.ISO8601DateTimeFormatter.Deserialize(JsonReader& reader, IJsonFormatterResolver formatterResolver)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
