Skip to content

Commit fc4a23e

Browse files
committed
Skip WeightedAverage and MovingFunction aggregations on < 6.4.0
1 parent cfa1af6 commit fc4a23e

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/Tests/Tests/Aggregations/Bucket/Composite/CompositeAggregationUsageTests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,11 @@ protected override void ExpectResponse(ISearchResponse<Project> response)
190190
var nested = item.Nested("project_tags");
191191
nested.Should().NotBeNull();
192192

193-
var nestedTerms = nested.Terms("tags");
194-
nestedTerms.Buckets.Count.Should().BeGreaterThan(0);
193+
if (nested.DocCount > 0)
194+
{
195+
var nestedTerms = nested.Terms("tags");
196+
nestedTerms.Buckets.Count.Should().BeGreaterThan(0);
197+
}
195198
}
196199
}
197200
}

src/Tests/Tests/Aggregations/Metric/WeightedAverage/WeightedAverageAggregationUsageTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using Elastic.Xunit.XunitPlumbing;
23
using FluentAssertions;
34
using Nest;
45
using Tests.Framework.Integration;
@@ -17,8 +18,11 @@ namespace Tests.Aggregations.Metric.WeightedAverage
1718
* value. Weighted averages, on the other hand, weight each datapoint differently. The amount that each
1819
* datapoint contributes to the final value is extracted from the document, or provided by a script.
1920
*
21+
* NOTE: Only available in Elasticsearch 6.4.0+
22+
*
2023
* Be sure to read the Elasticsearch documentation on {ref_current}/search-aggregations-metrics-weight-avg-aggregation.html[Weighted Avg Aggregation]
2124
*/
25+
[SkipVersion("<6.4.0", "Introduced in Elasticsearch 6.4.0+")]
2226
public class WeightedAverageAggregationUsageTests : AggregationUsageTestBase
2327
{
2428
public WeightedAverageAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { }

src/Tests/Tests/Aggregations/Pipeline/MovingFunction/MovingFunctionAggregationUsageTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@
1111

1212
namespace Tests.Aggregations.Pipeline.MovingFunction
1313
{
14+
/**
15+
* Given an ordered series of data, the Moving Function aggregation will slide a window across the data and allow
16+
* the user to specify a custom script that is executed on each window of data. For convenience, a number of
17+
* common functions are predefined such as min/max, moving averages, etc.
18+
*
19+
* This is conceptually very similar to the Moving Average pipeline aggregation, except it provides more functionality.
20+
*
21+
* NOTE: Only available in Elasticsearch 6.4.0+
22+
*
23+
* Be sure to read the Elasticsearch documentation on {ref_current}/search-aggregations-pipeline-movfn-aggregation.html[Moving Function Aggregation]
24+
*/
25+
[SkipVersion("<6.4.0", "Introduced in Elasticsearch 6.4.0+")]
1426
public class MovingFunctionAggregationUsageTests : AggregationUsageTestBase
1527
{
1628
public MovingFunctionAggregationUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { }

0 commit comments

Comments
 (0)