From df2b4a351ae7e055c5b4c265bf5ed9580d579712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20Emre=20Arma=C4=9Fan?= Date: Mon, 15 Apr 2024 18:19:22 +0100 Subject: [PATCH] Add GeohexGrid aggregation (#1591) (cherry picked from commit acd63a84c1510f67fe621d10d3a79003fc6ea39c) --- elasticsearch_dsl/aggs.py | 4 ++++ tests/test_aggs.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/elasticsearch_dsl/aggs.py b/elasticsearch_dsl/aggs.py index d9412e26..69c2d85e 100644 --- a/elasticsearch_dsl/aggs.py +++ b/elasticsearch_dsl/aggs.py @@ -209,6 +209,10 @@ class GeohashGrid(Bucket): name = "geohash_grid" +class GeohexGrid(Bucket): + name = "geohex_grid" + + class GeotileGrid(Bucket): name = "geotile_grid" diff --git a/tests/test_aggs.py b/tests/test_aggs.py index 936c2bcd..aa928de4 100644 --- a/tests/test_aggs.py +++ b/tests/test_aggs.py @@ -262,6 +262,12 @@ def test_geohash_grid_aggregation(): assert {"geohash_grid": {"field": "centroid", "precision": 3}} == a.to_dict() +def test_geohex_grid_aggregation(): + a = aggs.GeohexGrid(**{"field": "centroid", "precision": 3}) + + assert {"geohex_grid": {"field": "centroid", "precision": 3}} == a.to_dict() + + def test_geotile_grid_aggregation(): a = aggs.GeotileGrid(**{"field": "centroid", "precision": 3})