【问题标题】:nest API 5.3 [Elasticproperty]嵌套 API 5.3 [弹性属性]
【发布时间】:2017-04-08 09:11:10
【问题描述】:

我正在为 elasticsearch nest 5.3 版试用新的 .netapi,但我无法将属性类型声明为

[ElasticProperty(Name = "sys_updated_on", Store = true, Index = FieldIndexOption.NotAnalyzed, Type = FieldType.Date)
  public DateTimeOffset sys_updated_on { get; set; }

如何在新的 Nest 版本 5.3 中声明这一点。请帮忙!

【问题讨论】:

    标签: .net elasticsearch nest


    【解决方案1】:

    ElasticPropertyAttribute was deprecated in NEST 2.0+ in favour of type specific attributes. 在这种情况下,替换为

    [Date(Name = "sys_updated_on", Store = true)]
    public DateTimeOffset sys_updated_on { get; set; }
    

    几点

    1. Index = FieldIndexOption.NotAnalyzedDate 上无效(属性被拆分为不同类型的原因之一);它是否已编入索引,并在属性映射中表示为 bool
    2. 如果您使用名称 "sys_updated_on" 进行索引,则可以使用惯用的 .NET 属性名称,例如SysUpdatedOn
    3. 除非您需要单独使用stored_fields检索字段,否则原始值将被存储并可以从_source检索,因此不需要使用Store = true

    【讨论】:

      猜你喜欢
      • 2016-10-16
      • 2015-08-25
      • 1970-01-01
      • 1970-01-01
      • 2014-12-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-15
      • 2011-02-25
      相关资源
      最近更新 更多