简体   繁体   中英

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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