Skip to content

Separate types for histogram and date histogram items #1706

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 13, 2016
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
2 changes: 1 addition & 1 deletion src/Nest/Aggregations/AggregationJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private IAggregation GetDateHistogramAggregation(JsonReader reader, JsonSerializ
var docCount = (reader.Value as long?).GetValueOrDefault(0);
reader.Read();

var dateHistogram = new HistogramItem() { Key = key, KeyAsString = keyAsString, DocCount = docCount };
var dateHistogram = new DateHistogramItem() { Key = key, KeyAsString = keyAsString, DocCount = docCount };
dateHistogram.Aggregations = this.GetNestedAggregations(reader, serializer);
return dateHistogram;

Expand Down
4 changes: 2 additions & 2 deletions src/Nest/Aggregations/AggregationsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ public Bucket<RangeItem> GeoDistance(string key)
: new Bucket<RangeItem> {Items = bucket.Items.OfType<RangeItem>().ToList()};
}

public Bucket<HistogramItem> DateHistogram(string key)
public Bucket<DateHistogramItem> DateHistogram(string key)
{
var bucket = this.TryGet<Bucket>(key);
return bucket == null
? null
: new Bucket<HistogramItem> {Items = bucket.Items.OfType<HistogramItem>().ToList()};
: new Bucket<DateHistogramItem> {Items = bucket.Items.OfType<DateHistogramItem>().ToList()};
}
}
}
14 changes: 14 additions & 0 deletions src/Nest/Aggregations/Bucket/DateHistogram/DateHistogramItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Nest
{
public class DateHistogramItem : HistogramItem
{
// Get a DateTime form of the returned key
public DateTime Date => new DateTime(1970, 1, 1).AddMilliseconds(0 + this.Key);
}
}
6 changes: 0 additions & 6 deletions src/Nest/Aggregations/Bucket/Histogram/HistogramItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ public HistogramItem(IDictionary<string, IAggregation> aggregations) : base(aggr

public long Key { get; set; }
public string KeyAsString { get; set; }

/// <summary>
/// Get a DateTime form of the returned key, only make sense on date_histogram aggregations.
/// </summary>
public DateTime Date => new DateTime(1970, 1, 1).AddMilliseconds(0 + this.Key);

public long DocCount { get; set; }
}
}
1 change: 1 addition & 0 deletions src/Nest/Nest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<Reference Include="System.ServiceModel" />
</ItemGroup>
<ItemGroup>
<Compile Include="Aggregations\Bucket\DateHistogram\DateHistogramItem.cs" />
<Compile Include="Aggregations\Bucket\DocCountBucket.cs" />
<Compile Include="Aggregations\Bucket\Sampler\SamplerAggregation.cs" />
<Compile Include="Aggregations\Bucket\Sampler\SamplerAggregationExecutionHint.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.0.1
# whether we want to forcefully reseed on the node, if you are starting the tests with a node already running
Expand Down