c# - Nest 1.0 Elasticsearch,将DateTime索引为ISO 8601

标签 c# elasticsearch nest

我正在使用Nest 1.0和elasticsearch 1.0。我正在索引POCO对象,并且定义了一个映射:

_elasticsearchClient.Map<Customer>(c => c
    .Index("customers")
    .DynamicDateFormats(new[] { "dateOptionalTime", "yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z" })
    .DateDetection(true)
.NumericDetection(true)
    .AllField(a => a
        .Enabled()
        .IndexAnalyzer("nGram_analyzer")
        .SearchAnalyzer("whitespace_analyzer")
        .TermVector(TermVectorOption.with_positions_offsets))
    .Properties(props => props
        .Date(s => s
            .Name(p => p.Created).Format("dateOptionalTime").Store())));

但是当我检查该Date如何保存在索引中时,我得到:
创建于:/ Date(1399890590)/

我该如何解决?我检查了正在存储的映射

谢谢,

最佳答案

没有要修复的东西。 ElasticSearch通过转换为日期的Date's as long's表示来存储Unix Epoch。您的日期1399890590 = 2014年5月12日星期一10:29:50 GMT。

关于c# - Nest 1.0 Elasticsearch,将DateTime索引为ISO 8601,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23606840/

相关文章:

c# - 您能否对接口(interface)进行 Moq 模拟,并通过实现该接口(interface)的类型的强制转换和空检查?

c# - MVC的Display装饰器和使用EditorFor应用的View是什么关系?

c# - 如何检查列表中是否包含 NEST 中的术语?

elasticsearch - Elastic Search NEST-当我们提到类型名称时,搜索不返回任何记录

没有静态类型的 C# 接口(interface)

c# - EF Core 6.0 无效操作异常 : The object has been removed from the model

elasticsearch - 无法在弹性7.5.1中启动Packetbeat

elasticsearch - 使用 http 输入配置 Elasticsearch、Kibana 5、Logstash

elasticsearch - 我可以将下面的mysql查询更改为elasticsearch dsl吗?

elasticsearch - 如何使FacetFilter正常工作?