5
5
6
6
namespace Nest
7
7
{
8
+ /// <summary>
9
+ /// A multi-bucket aggregation that works on geo_point fields and groups points into buckets that represent cells in a grid.
10
+ /// The resulting grid can be sparse and only contains cells that have matching data.
11
+ /// Each cell is labeled using a geohash which is of user-definable precision.
12
+ /// </summary>
8
13
[ InterfaceDataContract ]
9
14
[ ReadAs ( typeof ( GeoHashGridAggregation ) ) ]
10
15
public interface IGeoHashGridAggregation : IBucketAggregation
11
16
{
17
+ /// <summary>
18
+ /// The name of the field indexed with geopoints.
19
+ /// </summary>
12
20
[ DataMember ( Name = "field" ) ]
13
21
Field Field { get ; set ; }
14
22
23
+ /// <summary>
24
+ /// The string length of the geohashes used to define cells/buckets in the results.
25
+ /// Defaults to <see cref="GeoHashPrecision.Precision5"/>.
26
+ /// </summary>
15
27
[ DataMember ( Name = "precision" ) ]
16
28
GeoHashPrecision ? Precision { get ; set ; }
17
29
30
+ /// <summary>
31
+ /// To allow for more accurate counting of the top cells returned in the final result the aggregation defaults to returning
32
+ /// <c>max(10,(size x number-of-shards))</c> buckets from each shard. If this heuristic is undesirable,
33
+ /// the number considered from each shard can be over-ridden using this parameter.
34
+ /// </summary>
18
35
[ DataMember ( Name = "shard_size" ) ]
19
36
int ? ShardSize { get ; set ; }
20
37
38
+ /// <summary>
39
+ /// The maximum number of geohash buckets to return. Defaults to <c>10,000</c>. When results are trimmed,
40
+ /// buckets are prioritised based on the volumes of documents they contain.
41
+ /// </summary>
21
42
[ DataMember ( Name = "size" ) ]
22
43
int ? Size { get ; set ; }
44
+
45
+ /// <summary>
46
+ /// Restricts the points considered to those that fall within the bounds provided.
47
+ /// <para />
48
+ /// Available in Elasticsearch 7.6.0+.
49
+ /// </summary>
50
+ [ DataMember ( Name = "bounds" ) ]
51
+ IBoundingBox Bounds { get ; set ; }
23
52
}
24
53
54
+ /// <inheritdoc cref="IGeoHashGridAggregation"/>
25
55
public class GeoHashGridAggregation : BucketAggregationBase , IGeoHashGridAggregation
26
56
{
27
57
internal GeoHashGridAggregation ( ) { }
28
58
29
59
public GeoHashGridAggregation ( string name ) : base ( name ) { }
30
60
61
+ /// <inheritdoc cref="IGeoHashGridAggregation.Field"/>
31
62
public Field Field { get ; set ; }
63
+
64
+ /// <inheritdoc cref="IGeoHashGridAggregation.Precision"/>
32
65
public GeoHashPrecision ? Precision { get ; set ; }
66
+
67
+ /// <inheritdoc cref="IGeoHashGridAggregation.ShardSize"/>
33
68
public int ? ShardSize { get ; set ; }
69
+
70
+ /// <inheritdoc cref="IGeoHashGridAggregation.Size"/>
34
71
public int ? Size { get ; set ; }
35
72
73
+ /// <inheritdoc cref="IGeoHashGridAggregation.Bounds"/>
74
+ public IBoundingBox Bounds { get ; set ; }
75
+
36
76
internal override void WrapInContainer ( AggregationContainer c ) => c . GeoHash = this ;
37
77
}
38
78
@@ -42,22 +82,30 @@ public class GeoHashGridAggregationDescriptor<T>
42
82
where T : class
43
83
{
44
84
Field IGeoHashGridAggregation . Field { get ; set ; }
45
-
46
85
GeoHashPrecision ? IGeoHashGridAggregation . Precision { get ; set ; }
47
-
48
86
int ? IGeoHashGridAggregation . ShardSize { get ; set ; }
49
-
50
87
int ? IGeoHashGridAggregation . Size { get ; set ; }
88
+ IBoundingBox IGeoHashGridAggregation . Bounds { get ; set ; }
51
89
90
+ /// <inheritdoc cref="IGeoHashGridAggregation.Field"/>
52
91
public GeoHashGridAggregationDescriptor < T > Field ( Field field ) => Assign ( field , ( a , v ) => a . Field = v ) ;
53
92
93
+ /// <inheritdoc cref="IGeoHashGridAggregation.Field"/>
54
94
public GeoHashGridAggregationDescriptor < T > Field < TValue > ( Expression < Func < T , TValue > > field ) => Assign ( field , ( a , v ) => a . Field = v ) ;
55
95
96
+ /// <inheritdoc cref="IGeoHashGridAggregation.Size"/>
56
97
public GeoHashGridAggregationDescriptor < T > Size ( int ? size ) => Assign ( size , ( a , v ) => a . Size = v ) ;
57
98
99
+ /// <inheritdoc cref="IGeoHashGridAggregation.ShardSize"/>
58
100
public GeoHashGridAggregationDescriptor < T > ShardSize ( int ? shardSize ) => Assign ( shardSize , ( a , v ) => a . ShardSize = v ) ;
59
101
102
+ /// <inheritdoc cref="IGeoHashGridAggregation.Precision"/>
103
+ // TODO: Rename to precision in next major.
60
104
public GeoHashGridAggregationDescriptor < T > GeoHashPrecision ( GeoHashPrecision ? precision ) =>
61
105
Assign ( precision , ( a , v ) => a . Precision = v ) ;
106
+
107
+ /// <inheritdoc cref="IGeoHashGridAggregation.Bounds"/>
108
+ public GeoHashGridAggregationDescriptor < T > Bounds ( Func < BoundingBoxDescriptor , IBoundingBox > selector ) =>
109
+ Assign ( selector , ( a , v ) => a . Bounds = v ? . Invoke ( new BoundingBoxDescriptor ( ) ) ) ;
62
110
}
63
111
}
0 commit comments