When working with Nest client and doing a search, the Docs collection can be rendered as a dynamic object
var response = es.Search<dynamic>(s => s.MatchAll());
When doing an mget, the response returns a collection of hits which will have the Source property. What is the best way to convert the source to be the same as what we have in the Documents collection from a search result.
Below is the code snippet I am using.
//create list of multiget operations
var ids = new List<MultiGetOperation<dynamic>>();
foreach (var id in uniqueKeys.Keys)
{
ids.Add(new MultiGetOperation<dynamic>(id)
{
Type = "doc",
Index = uniqueKeys[id].Index //documents can live in different indices
});
}
//return the hits from elastic
var results = es.MultiGet(
new MultiGetRequest
{
Documents = ids,
});
foreach( var hit in results.Hits)
{
// not sure what to do here as this does not work
dynamic h = hit.Source;
uniqueKeys[h.item_id].Info = h;
}