Skip to content

Commit 1d4f3a5

Browse files
committed
Dedicated TermsBucket type to propagate sum_other_doc_count and doc_count_error_upper_bound
1 parent 043128e commit 1d4f3a5

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/Nest/Aggregations/AggregationsHelper.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,19 @@ public DocCountBucket<SignificantTermItem> SignificantTerms(string key)
100100
};
101101
}
102102

103-
public Bucket<KeyedBucketItem> Terms(string key) => GetBucket<KeyedBucketItem>(key);
103+
public TermsBucket Terms(string key)
104+
{
105+
var bucket = this.TryGet<BucketDto>(key);
106+
return bucket == null
107+
? null
108+
: new TermsBucket
109+
{
110+
DocCountErrorUpperBound = bucket.DocCountErrorUpperBound,
111+
SumOtherDocCount = bucket.SumOtherDocCount,
112+
Items = bucket.Items.OfType<KeyedBucketItem>().ToList(),
113+
Meta = bucket.Meta
114+
};
115+
}
104116

105117
public Bucket<HistogramItem> Histogram(string key)
106118
{
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
namespace Nest
7+
{
8+
public class TermsBucket : Bucket<KeyedBucketItem>
9+
{
10+
public long? DocCountErrorUpperBound { get; set; }
11+
public long? SumOtherDocCount { get; set; }
12+
}
13+
}

src/Tests/Aggregations/Bucket/Terms/TermsAggregationUsageTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ protected override void ExpectResponse(ISearchResponse<Project> response)
9494
response.IsValid.Should().BeTrue();
9595
var states = response.Aggs.Terms("states");
9696
states.Should().NotBeNull();
97+
states.DocCountErrorUpperBound.Should().HaveValue();
98+
states.SumOtherDocCount.Should().HaveValue();
9799
foreach (var item in states.Items)
98100
{
99101
item.Key.Should().NotBeNullOrEmpty();

0 commit comments

Comments
 (0)