Skip to content

Expose constructor with inner aggregation dictionary #1206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2015
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
8 changes: 5 additions & 3 deletions src/Nest/Domain/Aggregations/BucketAggregationBase.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
namespace Nest
using System.Collections.Generic;
namespace Nest
{
public abstract class BucketAggregationBase : AggregationsHelper , IBucketAggregation
{

{
protected BucketAggregationBase() { }
protected BucketAggregationBase(IDictionary<string, IAggregation> aggregations) : base(aggregations) { }
}
}
9 changes: 7 additions & 2 deletions src/Nest/Domain/Aggregations/SingleBucket.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
using System.Collections.Generic;

namespace Nest
{
public class SingleBucket : BucketAggregationBase
{
{
public SingleBucket() { }

public SingleBucket(IDictionary<string, IAggregation> aggregations) : base(aggregations) { }

[JsonProperty("doc_count")]
public long DocCount { get; set; }
}
Expand Down
1 change: 1 addition & 0 deletions src/Tests/Nest.Tests.Unit/Nest.Tests.Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@
<Compile Include="Reproduce\Reproduce876Tests.cs" />
<Compile Include="Reproduce\Reproduce926Tests.cs" />
<Compile Include="Search\Aggregations\ScriptedMetricJson.cs" />
<Compile Include="Search\Aggregations\SingleBucketAggregationTests.cs" />
<Compile Include="Search\Failures\ShardFailureTests.cs" />
<Compile Include="Search\Fields\FieldsTests.cs" />
<Compile Include="Search\Filter\Modes\ConditionlessFilterJson.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using FluentAssertions;

namespace Nest.Tests.Unit.Search.Aggregations
{
[TestFixture]
public class SingleBucketAggregationTests
{
[Test]
public void CanSetInnerAggregationsInConstructor()
{
var bucket = new SingleBucket(new Dictionary<string, IAggregation> {
{"some_agg", new KeyItem { Key = "agg_key", DocCount = 123 }}
});

bucket.Aggregations.Should().ContainKey("some_agg");

var item = (KeyItem) bucket.Aggregations["some_agg"];
item.DocCount.Should().Be(123);
item.Key.Should().Be("agg_key");

}
}
}