コード例 #1
0
        public void Nested_Avg()
        {
            var q = new Query <Customer>(true).NestedAggregation(customer => customer.Products,
                                                                 AggregationsHelper.AvgAggregation <Customer>(
                                                                     customer => customer.Products.PropertyName(p => p.Price)))
                    .SetSize(0);

            var result = new DocumentSearch <Customer>().Search(_client, q);

            Assert.AreEqual(1000, result.Hits.Total);

            var nested = result.NestedAggregation(customer => customer.Products);

            Assert.IsNotNull(nested.Nested.Value);
        }