C# 将对象属性字段复制到主文档字段
我的模型如下:C# 将对象属性字段复制到主文档字段,c#,
elasticsearch,nest,C#,
elasticsearch,Nest,我的模型如下: class Entity { public List<Prop> PropList { get; set; } public List<string> Props { get; set; } // others } class Prop { public string Name { get; set; } public List<string> Tags { get; set; } } 默认情况下,PropLi
class Entity
{
public List<Prop> PropList { get; set; }
public List<string> Props { get; set; }
// others
}
class Prop
{
public string Name { get; set; }
public List<string> Tags { get; set; }
}
默认情况下,
PropList
将包含在\u source
中。是否有理由将它们复制到道具中?您仍然可以在PropList
中查询名称,但您可能希望将它们映射为嵌套的
数据类型,而不是对象
:我希望跨多个索引/类型进行搜索。其他类型只有道具
字段,它只是名称的列表
,没有标记
。
.Mappings(des => des
.AutoMap()
.Properties(propsDes => propsDes
.Object<Prop>(objDes => objDes
.Name(propDes => propDes.PropList)
.AutoMap()
.Properties(objPropsDes => objPropsDes
.Text(s => s
.Name(e => e.Name)
.CopyTo(fieldDes => fieldDes.Field("props"))
)
)
)
)
)