Skip to content

Pipeline aggs #1967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 45 additions & 12 deletions src/Nest/Aggregations/AggregationContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,18 @@ public interface IAggregationContainer
IMinBucketAggregation MinBucket { get; set; }

[JsonProperty("sum_bucket")]
ISumBucketAggregation SumBucket { get; set; }

[JsonProperty("moving_avg")]
ISumBucketAggregation SumBucket { get; set; }

[JsonProperty("stats_bucket")]
IStatsBucketAggregation StatsBucket { get; set; }

[JsonProperty("extended_stats_bucket")]
IExtendedStatsBucketAggregation ExtendedStatsBucket { get; set; }

[JsonProperty("percentiles_bucket")]
IPercentilesBucketAggregation PercentilesBucket { get; set; }

[JsonProperty("moving_avg")]
IMovingAverageAggregation MovingAverage { get; set; }

[JsonProperty("cumulative_sum")]
Expand Down Expand Up @@ -242,9 +251,15 @@ public class AggregationContainer : IAggregationContainer

public IMinBucketAggregation MinBucket { get; set; }

public ISumBucketAggregation SumBucket { get; set; }

public IMovingAverageAggregation MovingAverage { get; set; }
public ISumBucketAggregation SumBucket { get; set; }

public IStatsBucketAggregation StatsBucket { get; set; }

public IExtendedStatsBucketAggregation ExtendedStatsBucket { get; set; }

public IPercentilesBucketAggregation PercentilesBucket { get; set; }

public IMovingAverageAggregation MovingAverage { get; set; }

public ICumulativeSumAggregation CumulativeSum { get; set; }

Expand Down Expand Up @@ -349,9 +364,15 @@ public class AggregationContainerDescriptor<T> : DescriptorBase<AggregationConta

IMinBucketAggregation IAggregationContainer.MinBucket { get; set; }

ISumBucketAggregation IAggregationContainer.SumBucket { get; set; }

IMovingAverageAggregation IAggregationContainer.MovingAverage { get; set; }
ISumBucketAggregation IAggregationContainer.SumBucket { get; set; }

IStatsBucketAggregation IAggregationContainer.StatsBucket { get; set; }

IExtendedStatsBucketAggregation IAggregationContainer.ExtendedStatsBucket { get; set; }

IPercentilesBucketAggregation IAggregationContainer.PercentilesBucket { get; set; }

IMovingAverageAggregation IAggregationContainer.MovingAverage { get; set; }

ICumulativeSumAggregation IAggregationContainer.CumulativeSum { get; set; }

Expand Down Expand Up @@ -497,9 +518,21 @@ public AggregationContainerDescriptor<T> MinBucket(string name,

public AggregationContainerDescriptor<T> SumBucket(string name,
Func<SumBucketAggregationDescriptor, ISumBucketAggregation> selector) =>
_SetInnerAggregation(name, selector, (a, d) => a.SumBucket = d);

public AggregationContainerDescriptor<T> MovingAverage(string name,
_SetInnerAggregation(name, selector, (a, d) => a.SumBucket = d);

public AggregationContainerDescriptor<T> StatsBucket(string name,
Func<StatsBucketAggregationDescriptor, IStatsBucketAggregation> selector) =>
_SetInnerAggregation(name, selector, (a, d) => a.StatsBucket = d);

public AggregationContainerDescriptor<T> ExtendedStatsBucket(string name,
Func<ExtendedStatsBucketAggregationDescriptor, IExtendedStatsBucketAggregation> selector) =>
_SetInnerAggregation(name, selector, (a, d) => a.ExtendedStatsBucket = d);

public AggregationContainerDescriptor<T> PercentilesBucket(string name,
Func<PercentilesBucketAggregationDescriptor, IPercentilesBucketAggregation> selector) =>
_SetInnerAggregation(name, selector, (a, d) => a.PercentilesBucket = d);

public AggregationContainerDescriptor<T> MovingAverage(string name,
Func<MovingAverageAggregationDescriptor, IMovingAverageAggregation> selector) =>
_SetInnerAggregation(name, selector, (a, d) => a.MovingAverage = d);

Expand Down
20 changes: 13 additions & 7 deletions src/Nest/Aggregations/AggregationsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,19 @@ public ScriptedMetricAggregate ScriptedMetric(string key)

public StatsAggregate Stats(string key) => this.TryGet<StatsAggregate>(key);

public ExtendedStatsAggregate ExtendedStats(string key) => this.TryGet<ExtendedStatsAggregate>(key);

public GeoBoundsAggregate GeoBounds(string key) => this.TryGet<GeoBoundsAggregate>(key);

public PercentilesAggregate Percentiles(string key) => this.TryGet<PercentilesAggregate>(key);

public PercentilesAggregate PercentileRanks(string key) => this.TryGet<PercentilesAggregate>(key);
public StatsAggregate StatsBucket(string key) => this.TryGet<StatsAggregate>(key);

public ExtendedStatsAggregate ExtendedStats(string key) => this.TryGet<ExtendedStatsAggregate>(key);

public ExtendedStatsAggregate ExtendedStatsBucket(string key) => this.TryGet<ExtendedStatsAggregate>(key);

public GeoBoundsAggregate GeoBounds(string key) => this.TryGet<GeoBoundsAggregate>(key);

public PercentilesAggregate Percentiles(string key) => this.TryGet<PercentilesAggregate>(key);

public PercentilesAggregate PercentilesBucket(string key) => this.TryGet<PercentilesAggregate>(key);

public PercentilesAggregate PercentileRanks(string key) => this.TryGet<PercentilesAggregate>(key);

public TopHitsAggregate TopHits(string key) => this.TryGet<TopHitsAggregate>(key);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Newtonsoft.Json;

namespace Nest
{
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
[ContractJsonConverter(typeof(AggregationJsonConverter<ExtendedStatsBucketAggregation>))]
public interface IExtendedStatsBucketAggregation : IPipelineAggregation { }

public class ExtendedStatsBucketAggregation
: PipelineAggregationBase, IExtendedStatsBucketAggregation
{
internal ExtendedStatsBucketAggregation() { }

public ExtendedStatsBucketAggregation(string name, SingleBucketsPath bucketsPath)
: base(name, bucketsPath) { }

internal override void WrapInContainer(AggregationContainer c) => c.ExtendedStatsBucket = this;
}

public class ExtendedStatsBucketAggregationDescriptor
: PipelineAggregationDescriptorBase<ExtendedStatsBucketAggregationDescriptor, IExtendedStatsBucketAggregation, SingleBucketsPath>
, IExtendedStatsBucketAggregation
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Nest
{
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
[ContractJsonConverter(typeof(AggregationJsonConverter<PercentilesBucketAggregation>))]
public interface IPercentilesBucketAggregation : IPipelineAggregation
{
[JsonProperty("percents")]
IEnumerable<double> Percents { get; set; }
}

public class PercentilesBucketAggregation
: PipelineAggregationBase, IPercentilesBucketAggregation
{
public IEnumerable<double> Percents { get; set; }

internal PercentilesBucketAggregation() { }

public PercentilesBucketAggregation(string name, SingleBucketsPath bucketsPath)
: base(name, bucketsPath) { }

internal override void WrapInContainer(AggregationContainer c) => c.PercentilesBucket = this;
}

public class PercentilesBucketAggregationDescriptor
: PipelineAggregationDescriptorBase<PercentilesBucketAggregationDescriptor, IPercentilesBucketAggregation, SingleBucketsPath>
, IPercentilesBucketAggregation
{
IEnumerable<double> IPercentilesBucketAggregation.Percents { get; set; }

public PercentilesBucketAggregationDescriptor Percents(IEnumerable<double> percentages) =>
Assign(a => a.Percents = percentages?.ToList());

public PercentilesBucketAggregationDescriptor Percents(params double[] percentages) =>
Assign(a => a.Percents = percentages?.ToList());

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Newtonsoft.Json;

namespace Nest
{
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
[ContractJsonConverter(typeof(AggregationJsonConverter<StatsBucketAggregation>))]
public interface IStatsBucketAggregation : IPipelineAggregation { }

public class StatsBucketAggregation
: PipelineAggregationBase, IStatsBucketAggregation
{
internal StatsBucketAggregation() { }

public StatsBucketAggregation(string name, SingleBucketsPath bucketsPath)
: base(name, bucketsPath) { }

internal override void WrapInContainer(AggregationContainer c) => c.StatsBucket = this;
}

public class StatsBucketAggregationDescriptor
: PipelineAggregationDescriptorBase<StatsBucketAggregationDescriptor, IStatsBucketAggregation, SingleBucketsPath>
, IStatsBucketAggregation
{
}
}
Loading