Skip to content

Commit eb62e8a

Browse files
committed
Address PR comments
1 parent d6eee91 commit eb62e8a

File tree

5 files changed

+30
-16
lines changed

5 files changed

+30
-16
lines changed

src/Nest/Aggregations/Aggregate.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
namespace Nest
44
{
55
/// <summary>
6-
/// Represents the result of an aggregation on the response
6+
/// Aggregation response for an aggregation request
77
/// </summary>
88
[ExactContractJsonConverter(typeof(AggregateJsonConverter))]
99
public interface IAggregate
1010
{
1111
//TODO this public set is problematic
12+
/// <summary>
13+
/// Metadata for the aggregation
14+
/// </summary>
1215
IReadOnlyDictionary<string, object> Meta { get; set; }
1316
}
1417
}

src/Nest/Aggregations/AggregateDictionary.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,11 @@ public CompositeBucketAggregate Composite(string key)
179179
{
180180
var bucket = this.TryGet<BucketAggregate>(key);
181181
if (bucket == null) return null;
182-
return new CompositeBucketAggregate()
182+
return new CompositeBucketAggregate
183183
{
184184
Buckets = bucket.Items.OfType<CompositeBucket>().ToList(),
185185
Meta = bucket.Meta,
186-
AfterKey = bucket.AfterKey
186+
AfterKey = new CompositeKey(bucket.AfterKey)
187187
};
188188
}
189189

src/Nest/Aggregations/Bucket/BucketAggregate.cs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,43 @@ public SingleBucketAggregate(IReadOnlyDictionary<string, IAggregate> aggregation
2323
[Obsolete("Use methods on this instance to access sub aggregations. Will be removed in NEST 7.x")]
2424
public AggregateDictionary Aggregations { get; protected internal set; }
2525

26+
/// <summary>
27+
/// Count of documents in the bucket
28+
/// </summary>
2629
public long DocCount { get; internal set; }
2730
}
2831

32+
/// <summary>
33+
/// Aggregation response for a bucket aggregation
34+
/// </summary>
35+
/// <typeparam name="TBucket"></typeparam>
2936
public class MultiBucketAggregate<TBucket> : IAggregate
3037
where TBucket : IBucket
3138
{
39+
/// <inheritdoc />
3240
public IReadOnlyDictionary<string, object> Meta { get; set; }
3341

42+
/// <summary>
43+
/// The buckets into which results are grouped
44+
/// </summary>
3445
public IReadOnlyCollection<TBucket> Buckets { get; set; } = EmptyReadOnly<TBucket>.Collection;
3546
}
3647

37-
public class CompositeBucketAggregate : IAggregate
48+
/// <summary>
49+
/// Aggregation response of <see cref="CompositeAggregation"/>
50+
/// </summary>
51+
public class CompositeBucketAggregate : MultiBucketAggregate<CompositeBucket>
3852
{
39-
public IReadOnlyDictionary<string, object> Meta { get; set; }
40-
41-
public IReadOnlyCollection<CompositeBucket> Buckets { get; set; } = EmptyReadOnly<CompositeBucket>.Collection;
42-
4353
/// <summary>
44-
/// The after_key is equals to the last bucket returned in the response before any filtering that could be done by Pipeline aggregations.
45-
/// If all buckets are filtered/removed by a pipeline aggregation, the after_key will contain the last bucket before filtering.
54+
/// The composite key of the last bucket returned
55+
/// in the response before any filtering by pipeline aggregations.
56+
/// If all buckets are filtered/removed by pipeline aggregations,
57+
/// <see cref="AfterKey"/> will contain the composite key of the last bucket before filtering.
4658
/// </summary>
4759
/// <remarks> Valid for Elasticsearch 6.3.0+ </remarks>
48-
public IReadOnlyDictionary<string, object> AfterKey { get; set; } = EmptyReadOnly<string, object>.Dictionary;
60+
public CompositeKey AfterKey { get; set; }
4961
}
5062

51-
5263
// Intermediate object used for deserialization
5364
public class BucketAggregate : IAggregate
5465
{

src/Tests/Tests/Framework/EndpointTests/ApiIntegrationTestBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ protected ApiIntegrationTestBase(TCluster cluster, EndpointUsage usage) : base(c
3232
public override IElasticClient Client => this.Cluster.Client;
3333
protected override TInitializer Initializer => Activator.CreateInstance<TInitializer>();
3434

35-
[I] public virtual async Task ReturnsExpectedStatusCode() =>
35+
[I] public async Task ReturnsExpectedStatusCode() =>
3636
await this.AssertOnAllResponses(r => r.ApiCall.HttpStatusCode.Should().Be(this.ExpectStatusCode));
3737

38-
[I] public virtual async Task ReturnsExpectedIsValid() =>
38+
[I] public async Task ReturnsExpectedIsValid() =>
3939
await this.AssertOnAllResponses(r => r.ShouldHaveExpectedIsValid(this.ExpectIsValid));
4040

41-
[I] public virtual async Task ReturnsExpectedResponse() => await this.AssertOnAllResponses(ExpectResponse);
41+
[I] public async Task ReturnsExpectedResponse() => await this.AssertOnAllResponses(ExpectResponse);
4242

4343
protected override Task AssertOnAllResponses(Action<TResponse> assert)
4444
{

src/Tests/Tests/Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NoWarn>$(NoWarn);xUnit1013</NoWarn>
88
</PropertyGroup>
99
<ItemGroup>
10-
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta1-build3642" />
10+
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
1111
</ItemGroup>
1212
<ItemGroup>
1313
<ProjectReference Include="..\Tests.Core\Tests.Core.csproj" />

0 commit comments

Comments
 (0)