Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

elasticsearch nested aggregation in c#

var aggs = new AggregationDictionary()
{
    {
        "countries_step1",
        new NestedAggregation("countries_step1")
        {
            Path = "country",
            Aggregations = new AggregationDictionary()
            {
                {
                    "countries_step2",
                    new FilterAggregation("countries_step2")
                    {
                        Filter = new BoolQuery
                        {
                            Must = new QueryContainer[]
                            {
                                new TermQuery
                                {
                                    Field = "country.isDisplayed",
                                    Value = true
                                }
                            }
                        },
                        Aggregations = new AggregationDictionary
                        {
                            {
                                "countries_step3",
                                new TermsAggregation("countries_step3")
                                {
                                    Field = "country.displayName.keyword",
                                    Size = 9999
                                }
                            }
                        }
                    }
                }
            }
        }
    }
};
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #elasticsearch #nested #aggregation
ADD COMMENT
Topic
Name
3+4 =