Skip to content

Commit a505866

Browse files
committed
integration tests for all but nested aggregations
1 parent d26f68d commit a505866

26 files changed

+636
-191
lines changed

src/Nest/DSL/Aggregations/AggregationDescriptor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public AggregationDescriptor<T> GeoDistance(string name,
6464
return _SetInnerAggregation(name, selector, (a, d) => a._GeoDistance = d);
6565
}
6666

67-
[JsonProperty("geo_hash")]
67+
[JsonProperty("geohash_grid")]
6868
internal GeoHashAggregationDescriptor<T> _GeoHash { get; set; }
6969
public AggregationDescriptor<T> GeoHash(string name,
7070
Func<GeoHashAggregationDescriptor<T>, GeoHashAggregationDescriptor<T>> selector)
@@ -89,9 +89,9 @@ public AggregationDescriptor<T> Global(string name,
8989
}
9090

9191
[JsonProperty("ip_range")]
92-
internal IpRangeAggregationDescriptor<T> _IpRange { get; set; }
92+
internal Ip4RangeAggregationDescriptor<T> _IpRange { get; set; }
9393
public AggregationDescriptor<T> IpRange(string name,
94-
Func<IpRangeAggregationDescriptor<T>, IpRangeAggregationDescriptor<T>> selector)
94+
Func<Ip4RangeAggregationDescriptor<T>, Ip4RangeAggregationDescriptor<T>> selector)
9595
{
9696
return _SetInnerAggregation(name, selector, (a, d) => a._IpRange = d);
9797
}
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
using Nest.Resolvers.Converters;
12
using Newtonsoft.Json;
23

34
namespace Nest
45
{
6+
[JsonConverter(typeof(CustomJsonConverter))]
57
public class GlobalAggregationDescriptor<T> : BucketAggregationBaseDescriptor<GlobalAggregationDescriptor<T>, T>
8+
, ICustomJson
69
where T : class
710
{
8-
[JsonProperty("global")] internal readonly object _Global = new object {};
11+
internal readonly object _Global = new object {};
12+
13+
object ICustomJson.GetCustomJson()
14+
{
15+
return this._Global;
16+
}
917
}
1018
}

src/Nest/DSL/Aggregations/HistogramAggregationDescriptor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Nest
99
{
10-
public class HistogramAggregationDescriptor<T> : MetricAggregationBaseDescriptor<HistogramAggregationDescriptor<T>, T>
10+
public class HistogramAggregationDescriptor<T> : BucketAggregationBaseDescriptor<HistogramAggregationDescriptor<T>, T>
1111
where T : class
1212
{
1313
[JsonProperty("field")]

src/Nest/DSL/Aggregations/Ip4RangeAggregationDescriptor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77

88
namespace Nest
99
{
10-
public class IpRangeAggregationDescriptor<T> : BucketAggregationBaseDescriptor<IpRangeAggregationDescriptor<T>, T>
10+
public class Ip4RangeAggregationDescriptor<T> : BucketAggregationBaseDescriptor<Ip4RangeAggregationDescriptor<T>, T>
1111
where T : class
1212
{
1313

1414
[JsonProperty("field")]
1515
internal PropertyPathMarker _Field { get; set; }
1616

17-
public IpRangeAggregationDescriptor<T> Field(string field)
17+
public Ip4RangeAggregationDescriptor<T> Field(string field)
1818
{
1919
this._Field = field;
2020
return this;
2121
}
2222

23-
public IpRangeAggregationDescriptor<T> Field(Expression<Func<T, object>> field)
23+
public Ip4RangeAggregationDescriptor<T> Field(Expression<Func<T, object>> field)
2424
{
2525
this._Field = field;
2626
return this;
@@ -29,7 +29,7 @@ public IpRangeAggregationDescriptor<T> Field(Expression<Func<T, object>> field)
2929
[JsonProperty(PropertyName = "ranges")]
3030
internal IEnumerable<Ip4Range> _Ranges { get; set; }
3131

32-
public IpRangeAggregationDescriptor<T> Ranges(params string[] ranges)
32+
public Ip4RangeAggregationDescriptor<T> Ranges(params string[] ranges)
3333
{
3434
var newRanges = from range in ranges let r = new Ip4Range().Mask(range) select r;
3535
this._Ranges = newRanges;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Collections.Generic;
2+
3+
namespace Nest
4+
{
5+
public class Bucket<TBucketItem> : BucketAggregationBase
6+
where TBucketItem : IBucketItem
7+
{
8+
public IList<TBucketItem> Items { get; set; }
9+
}
10+
public class Bucket : IAggregation
11+
{
12+
public IEnumerable<IAggregation> Items { get; set; }
13+
}
14+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Nest
2+
{
3+
public abstract class BucketAggregationBase : AggregationsHelper , IBucketAggregation
4+
{
5+
6+
}
7+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
3+
namespace Nest
4+
{
5+
public class DateHistogramItem : BucketAggregationBase, IBucketItem
6+
{
7+
public long Key { get; set; }
8+
public string KeyAsString { get; set; }
9+
10+
public DateTime Date
11+
{
12+
get
13+
{
14+
return new DateTime(1970, 1, 1).AddMilliseconds(0 + this.Key);
15+
}
16+
}
17+
18+
public long DocCount { get; set; }
19+
}
20+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace Nest
2+
{
3+
public class ExtendedStatsMetric : IMetricAggregation
4+
{
5+
public long Count { get; set; }
6+
public double? Min { get; set; }
7+
public double? Max { get; set; }
8+
public double? Average { get; set; }
9+
public double? Sum { get; set; }
10+
public double? SumOfSquares { get; set; }
11+
public double? Variance { get; set; }
12+
public double? StdDeviation { get; set; }
13+
}
14+
}

src/Nest/Domain/Aggregations/IAggration.cs

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -8,108 +8,4 @@ namespace Nest
88
public interface IAggregation
99
{
1010
}
11-
12-
public interface IMetricAggregation : IAggregation
13-
{
14-
}
15-
16-
public interface IBucketAggregation : IAggregation
17-
{
18-
IDictionary<string, IAggregation> Aggregations { get; }
19-
//AggregationsHelper Aggs { get; }
20-
}
21-
public abstract class BucketAggregationBase : AggregationsHelper , IBucketAggregation
22-
{
23-
//public IDictionary<string, IAggregation> Aggregations { get; internal protected set; }
24-
//private AggregationsHelper _agg = null;
25-
26-
//public AggregationsHelper Aggs
27-
//{
28-
// get { return _agg ?? (_agg = new AggregationsHelper(this.Aggregations)); }
29-
//}
30-
}
31-
32-
public class ValueMetric : IMetricAggregation
33-
{
34-
public double Value { get; set; }
35-
}
36-
37-
public class StatsMetric : IMetricAggregation
38-
{
39-
public long Count { get; set; }
40-
public double Min { get; set; }
41-
public double Max { get; set; }
42-
public double Average { get; set; }
43-
public double Sum { get; set; }
44-
}
45-
46-
public class ExtendedStatsMetric : IMetricAggregation
47-
{
48-
public long Count { get; set; }
49-
public double Min { get; set; }
50-
public double Max { get; set; }
51-
public double Average { get; set; }
52-
public double Sum { get; set; }
53-
public double SumOfSquares { get; set; }
54-
public double Variance { get; set; }
55-
public double StdDeviation { get; set; }
56-
}
57-
58-
59-
public class SingleBucket : BucketAggregationBase
60-
{
61-
public long DocCount { get; set; }
62-
}
63-
64-
public class NestedBucket : BucketAggregationBase
65-
{
66-
}
67-
68-
public class Bucket<TBucketItem> : BucketAggregationBase
69-
where TBucketItem : IBucketItem
70-
{
71-
public IList<TBucketItem> Items { get; set; }
72-
}
73-
74-
public class Bucket : IAggregation
75-
{
76-
public IEnumerable<IAggregation> Items { get; set; }
77-
}
78-
79-
public interface IBucketItem : IAggregation
80-
{
81-
}
82-
83-
public class KeyItem : BucketAggregationBase, IBucketItem
84-
{
85-
public string Key { get; set; }
86-
public long DocCount { get; set; }
87-
}
88-
89-
public class DateHistogramItem : BucketAggregationBase, IBucketItem
90-
{
91-
public long Key { get; set; }
92-
public string KeyAsString { get; set; }
93-
94-
public DateTime Date
95-
{
96-
get
97-
{
98-
return new DateTime(1970, 1, 1).AddMilliseconds(0 + this.Key);
99-
}
100-
}
101-
102-
public long DocCount { get; set; }
103-
}
104-
105-
public class RangeItem : BucketAggregationBase, IBucketItem
106-
{
107-
public string Key { get; set; }
108-
public double? From { get; set; }
109-
public string FromAsString { get; set; }
110-
public double? To { get; set; }
111-
public string ToAsString { get; set; }
112-
public long DocCount { get; set; }
113-
}
114-
11511
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System.Collections.Generic;
2+
3+
namespace Nest
4+
{
5+
public interface IBucketAggregation : IAggregation
6+
{
7+
IDictionary<string, IAggregation> Aggregations { get; }
8+
}
9+
}

0 commit comments

Comments
 (0)