Skip to content

Commit 66850b8

Browse files
committed
Merge branch 'develop' of github.com:elasticsearch/elasticsearch-net into develop
2 parents ef3c567 + 23e011d commit 66850b8

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

Diff for: src/Nest/Resolvers/Converters/Aggregations/AggregationConverter.cs

+8
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ private IAggregation GetKeyedBucketItem(JsonReader reader, JsonSerializer serial
179179

180180
var keyItem = new KeyItem();
181181
keyItem.Key = key.ToString();
182+
183+
if (property == "key_as_string")
184+
{
185+
// Skip key_as_string property for backwards compatibility (< ES 1.2)
186+
reader.Read();
187+
reader.Read();
188+
}
189+
182190
reader.Read(); //doc_count;
183191
var docCount = reader.Value as long?;
184192
keyItem.DocCount = docCount.GetValueOrDefault(0);

Diff for: src/Tests/Nest.Tests.Integration/Nest.Tests.Integration.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@
179179
<Compile Include="Reproduce\Reproduce211Tests.cs" />
180180
<Compile Include="Reproduce\Reproduce654Tests.cs" />
181181
<Compile Include="Reproduce\Reproduce659Tests.cs" />
182+
<Compile Include="Reproduce\Reproduce730Tests.cs" />
182183
<Compile Include="Reproduce\ReproduceConnectionStallsTests.cs" />
183184
<Compile Include="Search\FieldTests\FieldsTest.cs" />
184185
<Compile Include="Search\NamedFilter\NamedFilterTests.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 Reproduce730Tests : IntegrationTests
14+
{
15+
[Test]
16+
public void TermAggIntegerAsKeyProducesNullKeyItem()
17+
{
18+
var result = this._client.Search<ElasticsearchProject>(s => s
19+
.Aggregations(a => a
20+
.Terms("my_term_agg", t => t
21+
.Field(o => o.DoubleValue))));
22+
23+
result.IsValid.Should().BeTrue();
24+
var myTermAgg = result.Aggs.Terms("my_term_agg");
25+
myTermAgg.Items.Count.Should().BeGreaterThan(0);
26+
myTermAgg.Items[0].Key.Should().NotBeNull();
27+
myTermAgg.Items[0].DocCount.Should().BeGreaterThan(0);
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)