6

I'm learning elasticsearch+nest, i want to map a type into a net class:

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

but the code does not compile neither ElasticType and ElasticProperty is available.

I referenced nest.dll 2.1.1 and Elasticsearch.Net.dll 2.1.1 from nuget.

FDB
  • 971
  • 16
  • 32
  • 9
    Yes, there were some breaking changes in NEST 2.x. Have a look at [breaking changes note](https://github.com/elastic/elasticsearch-net/blob/master/docs/2.0-breaking-changes/nest-breaking-changes.md). `ElasticType` becomes `ElasticsearchType` and `ElasticProperty` becomes `String`(in your case). Hope it helps. – Rob Apr 12 '16 at 13:54
  • But it looks like there is a problem with using those new attributes... https://stackoverflow.com/questions/45352029/setting-not-analyzed-for-a-property-in-nest-5-5-0 – Michał J. Gąsior Jul 27 '17 at 13:49
  • i am getting similar error even with NEST 6.X – Adithya Sai May 16 '18 at 07:02

1 Answers1

1

1) For 6.6 you should use ElasticsearchType instead of ElasticType.

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

2) Add "using Nest;" to file where Car class resides (NEST Nuget package must be added to same project).

Dr.
  • 101
  • 1
  • 1
  • 5