【发布时间】:2020-10-04 16:11:48
【问题描述】:
public class Document {
public Guid Id {get;set;}
public string Name {get;set;}
public DocumentAttribute[] Attributes {get;set;}
}
public class DocumentAttribute {
public Guid AttributeId {get;set;}
public string Type {get;set;}
public object Value {get;set;}
}
DocumentAttribute.Type 包含值的类型(字符串、日期、...)
我可以这样映射它:
.Map<DocumentDto>(
m=>m
.Properties(p => p
.Text(s => s.Name(DocumentDto.DefaultAttributes.Name))
.Nested<DocumentAttribute>(da => da
.Name(DocumentDto.DefaultAttributes.Attributes)
.Properties(dap => dap
.Text(s => s.Name(n => n.AttributeId))
.Nested<object>(dav => dav.Name(n => n.Value))
)
)
)
);
如果我尝试索引包含多种类型(一个是日期)属性的文档,我会得到:
mapper cannot be changed from type [date] to [text]
【问题讨论】:
标签: c# elasticsearch nest