-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
The current RangeBucket
implementation ignores "from"
and "to"
for an ip_range
aggregation, by looking at the JSON token type when deserializing, and only deserializing when it is a number:
elasticsearch-net/src/Nest/Aggregations/AggregateJsonConverter.cs
Lines 576 to 587 in 28f3774
case Parser.From: | |
reader.Read(); | |
if (reader.ValueType == typeof(double)) | |
fromDouble = (double)reader.Value; | |
reader.Read(); | |
break; | |
case Parser.To: | |
reader.Read(); | |
if (reader.ValueType == typeof(double)) | |
toDouble = (double)reader.Value; | |
reader.Read(); | |
break; |
This ignores "from"
and "to"
string values for ip_range
aggregation, an example response being
{
"took" : 39,
"timed_out" : false,
"_shards" : {
"total" : 2,
"successful" : 2,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1100,
"max_score" : 0.0,
"hits" : [ ]
},
"aggregations" : {
"ip_range#ip_ranges" : {
"buckets" : [
{
"key" : "*-127.0.0.1",
"to" : "127.0.0.1",
"doc_count" : 52
},
{
"key" : "127.0.0.1-*",
"from" : "127.0.0.1",
"doc_count" : 48
}
]
}
}
}
Introduce an IpRangeBucket
type or make RangeBucket
a generic type, i.e.
public class RangeBucket<TRangeValue> : BucketBase, IBucket
{
public RangeBucket(IReadOnlyDictionary<string, IAggregate> dict) : base(dict) { }
public long DocCount { get; set; }
public TRangeValue From { get; set; }
public string FromAsString { get; set; }
public string Key { get; set; }
public TRangeValue To { get; set; }
public string ToAsString { get; set; }
}
An IpRangeBucket
type is probably better here, since FromAsString
and ToAsString
are not properties of the response.