在 NEST 2.0 中找不到 Add() 方法
本文关键字:Add 方法 找不到 NEST | 更新日期: 2023-09-27 18:37:01
这是我的NEST2.0 POCO声明:
[ElasticsearchType(Name = "MyDocument")]
public class MyDocument: DynamicResponse
{
[String(Store = false, Index = FieldIndexOption.NotAnalyzed)]
public string HistoryId{ get; set; }
[String(Store = false, Index = FieldIndexOption.NotAnalyzed)]
public string FileId { get; set; }
[Date(Store = false)]
public DateTime DateTime { get; set; }
}
这是它的映射:
elastic.Map<MyDocument>(m => m
.Index(indexName)
.AutoMap().AllField(a => a.Enabled(false))
.Dynamic()
.DynamicTemplates(dt => dt
.Add(t => t
.Name("pv_values_template")
.Match("ch_*")
.Mapping(m2 => m2
.Number(n => n
.Store(false)
.Index(NonStringIndexOption.NotAnalyzed)
.DocValues(true))))));
看起来.Add()
方法不再存在(它在 NEST 1.0 中工作正常)
Add
方法已重命名为DynamicTemplate
,签名也发生了一些变化,所以看看:
client.Map<Document>(m => m
.Index(indexName)
.AutoMap().AllField(a => a.Enabled(false))
.Dynamic()
.DynamicTemplates(dt => dt
.DynamicTemplate("pv_values_template", t => t
.Match("ch_*")
.Mapping(m2 => m2
.Number(n => n
.Store(false)
.DocValues(true))))));
可能您正在询问新映射中的.Index(NonStringIndexOption.NotAnalyzed)
选项在哪里。这个问题有一个非常好的描述,所以请看一下。
希望对您有所帮助。