Skip to content

Commit 6496830

Browse files
committed
Fix #1236: Metric agg response not read to completion when value is null
1 parent 97b2979 commit 6496830

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

src/Nest/Resolvers/Converters/Aggregations/AggregationConverter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ private IAggregation GetValueMetricOrAggregation(JsonReader reader, JsonSerializ
366366
if (scriptedMetric != null)
367367
return new ScriptedValueMetric { _Value = scriptedMetric };
368368

369+
reader.Read();
369370
return valueMetric;
370371
}
371372

src/Tests/Nest.Tests.Integration/Nest.Tests.Integration.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
<Compile Include="Reproduce\Reproduce1169Tests.cs" />
172172
<Compile Include="Reproduce\Reproduce1176Tests.cs" />
173173
<Compile Include="Reproduce\Reproduce1193Tests.cs" />
174+
<Compile Include="Reproduce\Reproduce1236Tests.cs" />
174175
<Compile Include="Reproduce\Reproduce769Tests.cs" />
175176
<Compile Include="Reproduce\Reproduce945Tests.cs" />
176177
<Compile Include="Reproduce\Reproduce953Tests.cs" />
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using FluentAssertions;
2+
using Nest.Tests.MockData.Domain;
3+
using NUnit.Framework;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
10+
namespace Nest.Tests.Integration.Reproduce
11+
{
12+
[TestFixture]
13+
public class Reproduce1236Tests : IntegrationTests
14+
{
15+
[Test]
16+
public void AggregationsMissingWithZeroHits()
17+
{
18+
var result = this.Client.Search<ElasticsearchProject>(s => s
19+
.Query(q => q
20+
.Term(p => p.Country, "doesnotexist")
21+
)
22+
.Aggregations(a => a
23+
.Terms("new", t => t
24+
.Field(p => p.Name)
25+
)
26+
.Min("first_occurence", min => min
27+
.Field(p => p.StartedOn)
28+
)
29+
.Max("last_occurence", max => max
30+
.Field(p => p.StartedOn)
31+
)
32+
)
33+
);
34+
35+
result.IsValid.Should().BeTrue();
36+
result.Aggregations.Count.Should().Be(3);
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)