diff --git a/src/Nest/Aggregations/Pipeline/MovingFunction/MovingFunctionAggregation.cs b/src/Nest/Aggregations/Pipeline/MovingFunction/MovingFunctionAggregation.cs index 050aa460313..7a567bfcefd 100644 --- a/src/Nest/Aggregations/Pipeline/MovingFunction/MovingFunctionAggregation.cs +++ b/src/Nest/Aggregations/Pipeline/MovingFunction/MovingFunctionAggregation.cs @@ -12,6 +12,9 @@ public interface IMovingFunctionAggregation : IPipelineAggregation [DataMember(Name ="window")] int? Window { get; set; } + + [DataMember(Name ="shift")] + int? Shift { get; set; } } public class MovingFunctionAggregation @@ -26,6 +29,8 @@ public MovingFunctionAggregation(string name, SingleBucketsPath bucketsPath) public int? Window { get; set; } + public int? Shift { get; set; } + internal override void WrapInContainer(AggregationContainer c) => c.MovingFunction = this; } @@ -35,9 +40,13 @@ public class MovingFunctionAggregationDescriptor { string IMovingFunctionAggregation.Script { get; set; } int? IMovingFunctionAggregation.Window { get; set; } + int? IMovingFunctionAggregation.Shift { get; set; } public MovingFunctionAggregationDescriptor Window(int? windowSize) => Assign(windowSize, (a, v) => a.Window = v); public MovingFunctionAggregationDescriptor Script(string script) => Assign(script, (a, v) => a.Script = v); + + public MovingFunctionAggregationDescriptor Shift(int? shift) => Assign(shift, (a, v) => a.Shift = v); + } } diff --git a/src/Tests/Tests/Aggregations/Pipeline/MovingFunction/MovingFunctionAggregationUsageTests.cs b/src/Tests/Tests/Aggregations/Pipeline/MovingFunction/MovingFunctionAggregationUsageTests.cs index ebb54d519ae..b9c8055bc4b 100644 --- a/src/Tests/Tests/Aggregations/Pipeline/MovingFunction/MovingFunctionAggregationUsageTests.cs +++ b/src/Tests/Tests/Aggregations/Pipeline/MovingFunction/MovingFunctionAggregationUsageTests.cs @@ -21,7 +21,7 @@ namespace Tests.Aggregations.Pipeline.MovingFunction * * Be sure to read the Elasticsearch documentation on {ref_current}/search-aggregations-pipeline-movfn-aggregation.html[Moving Function Aggregation] */ - [SkipVersion("<6.4.0", "Introduced in Elasticsearch 6.4.0+")] + [SkipVersion("<7.4.0", "Shift option introduced in 7.4.0+")] public class MovingFunctionAggregationUsageTests : AggregationUsageTestBase { public MovingFunctionAggregationUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } @@ -50,6 +50,7 @@ public MovingFunctionAggregationUsageTests(ReadOnlyCluster cluster, EndpointUsag { buckets_path = "commits", window = 30, + shift = 0, script = "MovingFunctions.unweightedAvg(values)" } } @@ -69,6 +70,7 @@ public MovingFunctionAggregationUsageTests(ReadOnlyCluster cluster, EndpointUsag .MovingFunction("commits_moving_avg", mv => mv .BucketsPath("commits") .Window(30) + .Shift(0) .Script("MovingFunctions.unweightedAvg(values)") ) ) @@ -84,6 +86,7 @@ public MovingFunctionAggregationUsageTests(ReadOnlyCluster cluster, EndpointUsag && new MovingFunctionAggregation("commits_moving_avg", "commits") { Window = 30, + Shift = 0, Script = "MovingFunctions.unweightedAvg(values)" } };