nest API 5.3 [弹性属性]
nest API 5.3 [Elasticproperty]
我正在为 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 版本中声明这一点。请帮忙!
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; }
几点
Index = FieldIndexOption.NotAnalyzed
在 Date
上无效(属性被拆分为不同类型的原因之一);它要么被索引,要么不被索引,并在属性映射 中表示为bool
- 如果您使用名称
"sys_updated_on"
建立索引,您可以使用惯用的 .NET 属性 名称,例如SysUpdatedOn
.
- 除非您需要使用
stored_fields
单独检索字段,否则将存储原始值并可从 _source
检索,因此不需要使用 Store = true
我正在为 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 版本中声明这一点。请帮忙!
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; }
几点
Index = FieldIndexOption.NotAnalyzed
在Date
上无效(属性被拆分为不同类型的原因之一);它要么被索引,要么不被索引,并在属性映射 中表示为- 如果您使用名称
"sys_updated_on"
建立索引,您可以使用惯用的 .NET 属性 名称,例如SysUpdatedOn
. - 除非您需要使用
stored_fields
单独检索字段,否则将存储原始值并可从_source
检索,因此不需要使用Store = true
bool