private TermsAggregationDescriptor <PersistentEvent> BuildTermSort(TermsAggregationDescriptor <PersistentEvent> aggregations, IEnumerable <FieldAggregation> fields) { var field = fields.FirstOrDefault(f => f.SortOrder.HasValue); if (field?.SortOrder == null) { return(aggregations); } return(field.SortOrder.Value == Foundatio.Repositories.Models.SortOrder.Ascending ? aggregations.OrderAscending(field.Key) : aggregations.OrderDescending(field.Key)); }
public void TermAggregationSerializes() { var s = new TermsAggregationDescriptor<ElasticsearchProject>() .CollectMode(TermsAggregationCollectMode.BreadthFirst) .ExecutionHint(TermsAggregationExecutionHint.GlobalOrdinalsLowCardinality) .Field(p => p.Country) .MinimumDocumentCount(1) .OrderAscending("_count"); this.JsonEquals(s, MethodBase.GetCurrentMethod()); }
public void TermAggregationSerializes() { var s = new TermsAggregationDescriptor <ElasticsearchProject>() .CollectMode(TermsAggregationCollectMode.BreadthFirst) .ExecutionHint(TermsAggregationExecutionHint.GlobalOrdinalsLowCardinality) .Field(p => p.Country) .MinimumDocumentCount(1) .OrderAscending("_count"); this.JsonEquals(s, MethodBase.GetCurrentMethod()); }
/// <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); }
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); }
/// <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); }
private TermsAggregationDescriptor<PersistentEvent> BuildTermSort(TermsAggregationDescriptor<PersistentEvent> aggregations, IEnumerable<FieldAggregation> fields) { var field = fields.FirstOrDefault(f => f.SortOrder.HasValue); if (field?.SortOrder == null) return aggregations; return field.SortOrder.Value == Foundatio.Repositories.Models.SortOrder.Ascending ? aggregations.OrderAscending(field.Key) : aggregations.OrderDescending(field.Key); }