Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Nest/Aggregations/AggregateJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,14 @@ private IAggregate GetMultiBucketAggregate(JsonReader reader, JsonSerializer ser
{
reader.Read();
var aggs = new Dictionary<string, IAggregate>();
do
while (reader.TokenType != JsonToken.EndObject)
{
var name = reader.Value.ToString();
reader.Read();
var innerAgg = this.ReadAggregate(reader, serializer);
aggs.Add(name, innerAgg);
reader.Read();
} while (reader.TokenType != JsonToken.EndObject);

}
reader.Read();
return new FiltersAggregate(aggs);
}
Expand Down
68 changes: 68 additions & 0 deletions src/Tests/Reproduce/AggsDeserialization.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tests.Framework;
using Tests.Framework.Integration;
using Tests.Framework.MockData;
using Xunit;

using Elasticsearch.Net;
using Nest;
using FluentAssertions;

namespace Tests.Reproduce
{
public class AggsDeserialization : IClusterFixture<ReadOnlyCluster>
{
private readonly ReadOnlyCluster _cluster;

public AggsDeserialization(ReadOnlyCluster cluster)
{
_cluster = cluster;
}

[I]
public void EmptyBucketsThrowsNullReferenceException()
{
var client = _cluster.Client;

var response = client.Search<Project>(s => s
.SearchType(SearchType.Count)
.Aggregations(a => a
.Terms("names", ts => ts
.Field(p => p.Name)
.Size(0)
.Order(TermsOrder.TermAscending)
.Aggregations(aa => aa
.Filters("filters", fs => fs
.NamedFilters(nfs => nfs
.Filter("foo", f => f
.Term(t => t
.Field(p => p.State)
.Value(StateOfBeing.Stable)
)
)
)
.Aggregations(aaa => aaa
.ValueCount("counts", vc => vc
.Field(p => p.NumberOfCommits)
)
.BucketSelector("counts_bucket_filter", bs => bs
.BucketsPath(bp => bp
.Add("totalCounts", "counts")
)
.Script("totalCounts < 0") // intentionally filter all documents to cause empty buckets object
)
)
)
)
)
)
);

response.IsValid.Should().BeTrue();
}
}
}
1 change: 1 addition & 0 deletions src/Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@
<Compile Include="QueryDsl\BoolDsl\Operators\OrAssignManyManualBoolsTests.cs" />
<Compile Include="QueryDsl\Span\FieldMasking\SpanFieldMaskingUsageTests.cs" />
<Compile Include="QueryDsl\Verbatim\VerbatimAndStrictQueryUsageTests.cs" />
<Compile Include="Reproduce\AggsDeserialization.cs" />
<Compile Include="Reproduce\GithubIssue2101.cs" />
<Compile Include="Reproduce\GithubIssue2152.cs" />
<Compile Include="Reproduce\GithubIssue2052.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# mode either u (unit test), i (integration test) or m (mixed mode)
mode: u
mode: i
# the elasticsearch version that should be started
elasticsearch_version: 2.4.0
# whether we want to forcefully reseed on the node, if you are starting the tests with a node already running
Expand Down