문제

I am trying NEST out and it seems very nice, but I am having some trouble understanding some things. The response is serialized to an hierarchy of objects. I would like to iterate over it and to create my own structure. I would be able to do somethings like this (thanks to @Martijn Laarman, who helped me in the GitHub page):

var buckets = result.Aggs.Terms("level_1");
var term = buckets.Items[0].Terms("level_2");

It works, but I would like to have a generic algorithm that parses the response. To do that, I would like to get content independently of the query (if it used terms, range, etc). So I would like to do things like:

var buckets = result.Aggregrations["level_1"];
var term = buckets.Items[0].Aggreggation["level_2"];

Unfortunately the Aggregations collection returns Nest.Bucket and I can't do anything from there. Is there any way that I can iterate over the result independently on how the query was formed?

Thanks!

도움이 되었습니까?

해결책

For sake of completeness, I was not able to find any way to do so. I created a parser using a mix of JObects and Dictionary and operated over the JSON response to generate the output I wanted.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top