使用NEST在索引上设置Elasticsearch时间戳路径吗?

问题描述 投票:2回答:1

我需要使用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个回答
4
投票

使用流畅的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)
  )
);

希望有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.