简体   繁体   English

Elasticsearch Nest如何进行多态索引

[英]Elasticsearch nest how to index polymorphically

Ok, 好,

Basically what I'd LIKE to do, is have a "Searchable" interface I implement on my entities, and have my repositories automatically call Index on save, and handle the update/delete accordingly. 基本上,我希望做的是在我的实体上实现一个“可搜索”接口,并让我的存储库在保存时自动调用Index,并相应地处理更新/删除。 This all currently works. 目前所有这些都有效。 Ultimately I'd like to search against all these indicies and be able to give some sort of indicator of the type itself. 最终,我想对所有这些索引进行搜索,并能够给出类型本身的某种指标。

When I try to query them all back out... I use code that looks like this: 当我尝试全部查询它们时...我使用如下代码:

 eclient.Search<Searchable>(s => s.AllIndices().Query(q => q.QueryString(d => d.Query(query))))

I don't get anything back from this unless I explicitly specify the type I'd like to return. 除非我明确指定要返回的类型,否则我从中不会得到任何回报。

Any pointers would be hugely appreciated. 任何指针将不胜感激。 At this point my object model is changeable if interface/baseclass makes a difference etc. 在这一点上,如果接口/基类有所作为等,我的对象模型是可变的。

Actually I was able to determine that my problem was actually more of a problem with what I was doing with the results. 实际上,我能够确定我的问题实际上是我对结果所做的问题。 JavascriptSerializer didnt know how to properly serialize the objects, whereas json.net did a lot better job. JavascriptSerializer不知道如何正确序列化对象,而json.net做得更好。

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

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