【问题标题】:ElasticType and ElasticProperty attributes non found on nest.dll 2.1.1在 nest.dll 2.1.1 上找不到 ElasticType 和 ElasticProperty 属性
【发布时间】:2019-03-07 20:59:05
【问题描述】:

我正在学习elasticsearch+nest,我想将一个类型映射到一个网络类中:

[ElasticType(Name="car")]
public class Car {} 
{
    [ElasticProperty(Name = "color", Index = FieldIndexOption.NotAnalyzed, Type = FieldType.String)]
    public string Color { get; set; }
}

但是代码没有编译,ElasticType 和 ElasticProperty 都不可用。

我从 nuget 引用了 nest.dll 2.1.1 和 Elasticsearch.Net.dll 2.1.1。

【问题讨论】:

  • 是的,NEST 2.x 中有一些重大变化。看看breaking changes noteElasticType 变为 ElasticsearchTypeElasticProperty 变为 String(在你的情况下)。希望对您有所帮助。
  • 但是使用这些新属性似乎有问题...stackoverflow.com/questions/45352029/…
  • 即使使用 NEST 6.X,我也会遇到类似的错误

标签: nest elasticsearch-net


【解决方案1】:

1) 对于 6.6,您应该使用 ElasticsearchType 而不是 ElasticType。

https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/attribute-mapping.html

2) 添加“使用 Nest;”到 Car 类所在的文件(必须将 NEST Nuget 包添加到同一项目中)。

【讨论】:

    猜你喜欢
    • 2019-11-02
    • 2013-01-25
    • 1970-01-01
    • 2015-02-02
    • 2016-01-18
    • 2015-01-22
    • 1970-01-01
    • 1970-01-01
    • 2019-08-24
    相关资源
    最近更新 更多