如何格式化日期elasticsearch
1.我的搜索查询
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"))
)
)
)
);
- 我的班级
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; }
}
- 无效的日期时间格式。值:2021-10-23 08:55:37
因为elasticsearch数据是“updatedate”:“2021-10-21 20:43:46”
这是异常:
异常:InvalidOperationException采取:00:00:00.1149820
步骤中的审核异常3 BadResponse:
System.InvalidOperationException:日期时间格式无效。价值:2021-10-23 08:55:37 在Elasticsearch.Net.Utf8Json.Formatters.ISO8601DateTimeFormatter.Deserialize(JsonReader&reader,IJsonFormatterResolver formatterResolver)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论