【问题标题】:Set Elasticsearch timestamp path on an index using NEST?使用 NEST 在索引上设置 Elasticsearch 时间戳路径?
【发布时间】:2014-06-30 15:18:26
【问题描述】:

我需要使用 NEST 向我的索引添加时间戳路径,但不知道如何实现: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-timestamp-field.html

我一直在搞乱 NEST,但我无法弄清楚。

我一直在阅读这里的文档,但没有找到我要查找的内容: http://nest.azurewebsites.net/nest/quick-start.html

【问题讨论】:

    标签: elasticsearch nest


    【解决方案1】:

    使用 fluent API,这可以在创建索引时完成:

    var response = client.CreateIndex("myindex", c => c
      .AddMapping<MyType>(m => m
        .MapFromAttributes()
        .TimestampField(t => t
          .SetDisabled(false)
          .SetPath(o => o.MyTimestampField)
        )
      )
    );
    

    或更新现有索引:

    var response = client.Map<MyType>(m => m
      .TimestampField(t => t
        .SetDisabled(false)
        .SetPath(o => o.MyTimestampField)
      )
    );
    

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-27
      • 1970-01-01
      • 2017-12-29
      • 2014-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多