Skip to content

Support extended_bounds on Histogram #1094

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
Dec 9, 2014
Merged
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
12 changes: 12 additions & 0 deletions src/Nest/DSL/Aggregations/HistogramAggregationDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public interface IHistogramAggregator : IBucketAggregator

[JsonProperty("order")]
IDictionary<string, string> Order { get; set; }

[JsonProperty("extended_bounds")]
IDictionary<string, object> ExtendedBounds { get; set; }
}

public class HistogramAggregator : BucketAggregator, IHistogramAggregator
Expand All @@ -37,6 +40,7 @@ public class HistogramAggregator : BucketAggregator, IHistogramAggregator
public double? Interval { get; set; }
public int? MinimumDocumentCount { get; set; }
public IDictionary<string, string> Order { get; set; }
public IDictionary<string, object> ExtendedBounds { get; set; }
}

public class HistogramAggregationDescriptor<T> : BucketAggregationBaseDescriptor<HistogramAggregationDescriptor<T>, T>, IHistogramAggregator
Expand All @@ -56,6 +60,8 @@ public class HistogramAggregationDescriptor<T> : BucketAggregationBaseDescriptor

IDictionary<string, string> IHistogramAggregator.Order { get; set; }

IDictionary<string, object> IHistogramAggregator.ExtendedBounds { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer a strongly typed ExtendBounds object with Min and Max as properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I just looked at how it was made in date histogram.

If i make a ExtendedBounds object, with two properties Min as Double and Max as Double, it's not posseible to reuse this object in DateHistogram, because it will be bounded to DateTime.

Maybe this is not a problem? What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dang, i think I screwed up there :) I'll pull your PR as is and add a TODO to move both to a typed object in NEST 2.0. We can't change properties in minor releases do to strict semver requirements.


public HistogramAggregationDescriptor<T> Field(string field)
{
Self.Field = field;
Expand Down Expand Up @@ -104,5 +110,11 @@ public HistogramAggregationDescriptor<T> OrderDescending(string key)
return this;
}

public HistogramAggregationDescriptor<T> ExtendedBounds(double min, double max)
{
Self.ExtendedBounds = new Dictionary<string, object> { { "min", min }, { "max", max } };
return this;
}

}
}