繁体   English   中英

如何在ElasticSearch派生类NEST中获取

[英]How to get in ElasticSearch derived class NEST

我创建索引我的类型产品。 产品内部具有指南命名对象。 Guide是示例Guide1 Guide2 Guide3 vs.的基类和继承类。

在再次创建产品类之后,我创建了Product对象并索引了弹性,但是这一次是Product中的Guide1类。

我通过ID获得产品嵌套,而不是将Guide1强制转换为产品。

public class Product{
   public string Name{get;set;}

   public Guide Guide{get;set;}
}

public class Guide{
    public int ID{get;set;}

    public string Title{get;set;}
}

public class Guide1 :  Guide{
    public double Price{get;set;}
}


Product p1 elasticContext.Get<Product>(1, idx => idx.Index("products"));

指南1强制转换为指南,但我无法访问Guide1属性

在嵌套连接设置中调用记录类型时,完整类型将返回

new ConnectionSettings(node, sourceSerializer: (b, s) => new JsonNetSerializer(b, s, () => new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM