Geo Tile Grid Aggregation Usageedit

Fluent DSL exampleedit

a => a
.GeoTile("my_geotile", g => g
    .Field(p => p.LocationPoint)
    .Precision(GeoTilePrecision.Precision3)
    .Size(1000)
    .ShardSize(100)
)

Object Initializer syntax exampleedit

new GeoTileGridAggregation("my_geotile")
{
    Field = Field<Project>(p => p.LocationPoint),
    Precision = GeoTilePrecision.Precision3,
    Size = 1000,
    ShardSize = 100
}

Example json output.

{
  "my_geotile": {
    "geotile_grid": {
      "field": "locationPoint",
      "precision": 3,
      "size": 1000,
      "shard_size": 100
    }
  }
}

Handling Responsesedit

response.ShouldBeValid();
var myGeoTileGrid = response.Aggregations.GeoTile("my_geotile");
myGeoTileGrid.Should().NotBeNull();
var firstBucket = myGeoTileGrid.Buckets.First();
firstBucket.Key.Should().NotBeNullOrWhiteSpace();
firstBucket.DocCount.Should().BeGreaterThan(0);