'CreateIndexDescriptor' 不包含 'AddMapping' 的定义

'CreateIndexDescriptor' does not contain a definition for 'AddMapping'

我是 Elasticsearch 的初学者。在执行 https://msdn.microsoft.com/en-us/magazine/dn904674.aspx 之类的示例应用程序时,它在

中显示错误
public void CreateMarketingIndex()
{
 this.client.CreateIndex("marketing", c =>.AddMapping<MarketingDocument>
     (m => m.Properties(ps => ps.Attachment
       (a => a.Name(o => o.Document)
         .TitleField(t => t.Name(x => x.Name).TermVector(TermVectorOption.WithPositionsOffsets))))));
} 

'CreateIndexDescriptor' does not contain a definition for 'AddMapping' and no extension method 'AddMapping' accepting a first argument of type 'CreateIndexDescriptor' could be found (are you missing a using directive or an assembly reference?)

我是否遗漏了任何参考资料。 我引用了 Elasticsearch.net 和 Nest

我认为AddMapping 可能是针对旧版本的Nest 客户端。我一直在使用映射。尝试这样的事情:

this.client.CreateIndex("marketing", c => c
    .Mappings(md => md
        .Map<MarketingDocument>(m => m.Properties(ps...

你可以这样做:

var descriptor = new CreateIndexDescriptor(mIndexName)
     .Mappings(x => x.Map<Model>(m => m.AutoMap()));

或没有对象类型

var descriptor = new CreateIndexDescriptor(mIndexName)
     .Mappings(x => x.Map(model, m => m.AutoMap()));