Пример #1
0
        /// <summary>
        /// Creates a nested aggregation. Wraps the aggregation on which it is called by a new Terms aggregation, using the provided fieldName.
        /// </summary>
        public static AggregationContainerDescriptor <T> GroupBy <T>(this AggregationContainerDescriptor <T> innerAggregation, string fieldName) where T : class
        {
            var v = new AggregationContainerDescriptor <T>();

            v.Terms(fieldName, tr =>
            {
                var trmAggDescriptor = new TermsAggregationDescriptor <T>();
                trmAggDescriptor.Field(fieldName);
                trmAggDescriptor.Size(int.MaxValue);
                return(trmAggDescriptor.Aggregations(x => innerAggregation));
            });

            return(v);
        }
Пример #2
0
        public static AggregationDescriptor <T> GroupBy <T>(this AggregationDescriptor <T> innerAggregation, String key) where T : class
        {
            AggregationDescriptor <T> v = new AggregationDescriptor <T>();

            v.Terms(key, tr =>
            {
                TermsAggregationDescriptor <T> trmAggDescriptor = new TermsAggregationDescriptor <T>();
                trmAggDescriptor.Field(key);
                trmAggDescriptor.Size(int.MaxValue);
                return(trmAggDescriptor.Aggregations(x => innerAggregation));
            });

            return(v);
        }
Пример #3
0
        /// <summary>
        /// Creates a nested aggregation. Wraps the aggregation on which it is called by a new Terms aggregation, using the provided fieldGetter function to terms on the field.
        /// </summary>
        public static AggregationContainerDescriptor <T> GroupBy <T>(this AggregationContainerDescriptor <T> innerAggregation, Expression <Func <T, object> > fieldGetter) where T : class
        {
            var fieldName = fieldGetter.GetAggName(AggType.GroupBy);
            var v         = new AggregationContainerDescriptor <T>();

            v.Terms(fieldName, tr =>
            {
                var trmAggDescriptor = new TermsAggregationDescriptor <T>();
                trmAggDescriptor.Field(fieldGetter);
                trmAggDescriptor.Size(int.MaxValue);
                return(trmAggDescriptor.Aggregations(x => innerAggregation));
            });

            return(v);
        }