我需要创建一个具有自定义名称的文档映射。目前,我的文档在CreateIndexDescriptor对象上具有以下映射:
.Mappings(m => m
.Map<MyDocType>(mDetails => mDetails.AutoMap()));
将创建一个名为mydoctype的文档映射。我该如何修改它才能创建一个类型名称为my_doctype的文档?
答案 0 :(得分:2)
在NEST 7.x中,这是不可能的-文档类型将为_doc
,in line with the roadmap for the removal of mapping types。
在NEST 6.x中,您可以specify the type name to use in a few different ways:
在POCO上使用ElasticsearchTypeAttribute
[ElasticsearchType(Name = "my_doctype")]
public class MyDocType{ }
在POCO上使用DataContractAttribute
[DataContract(Name = "my_doctype")]
public class MyDocType{ }
在.DefaultMappingFor<T>()
上使用ConnectionSettings
var settings = new ConnectionSettings()
.DefaultMappingFor<MyDocType>(m => m
.IndexName("my_doc_type_default_index")
.TypeName("my_doctype")
);
var client = new ElasticClient(settings);