elasticsearch,nest,C#,elasticsearch,Nest" /> elasticsearch,nest,C#,elasticsearch,Nest" />

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"))
           )
         )
      )
    )
  )