Skip to content

Commit 5eeb3e6

Browse files
authored
[elasticgraph]: Add geographic tile grouping (#1438)
## Why `GeoLocation` fields cannot currently be grouped in aggregation queries. This adds the geographic grouping API discussed in [#1426](#1426). ## What Adds `asGeoTile(zoomLevel: ...)`, with a default zoom level of 7. Each tile exposes `zoomLevel`, `x`, `y`, `centerPoint`, `bounds`, and `corners`. ## How Uses `geotile_grid` for both root and nested aggregations on Elasticsearch and OpenSearch. The response decodes the tile key into Web Mercator coordinates. Missing locations return a null tile, and root pagination compares tile coordinates in datastore order. Standalone nested geo grids use conservative count bounds because the datastore does not provide their count error bounds. ## Risk This adds a new grouping API. Existing filtering and non-geographic grouping behavior is unchanged. ## Testing No manual testing. Generated with Pi
1 parent 63ebea7 commit 5eeb3e6

71 files changed

Lines changed: 2697 additions & 93 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎config/proto_field_numbers.yaml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ messages:
283283
was_shortened: 7
284284
players_nested: 8
285285
players_object: 9
286-
next_number: 10
286+
stadium_location: 10
287+
next_number: 11
287288
Widget:
288289
fields:
289290
id: 1

‎config/schema/artifacts/data_warehouse.yaml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ tables:
106106
forbes_valuation_moneys_object ARRAY<STRUCT<currency STRING, amount_cents INT>>,
107107
current_players_nested ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>,
108108
current_players_object ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>,
109-
seasons_nested ARRAY<STRUCT<the_record STRUCT<win_count INT, loss_count INT, last_win_date DATE, first_win_on DATE>, year INT, notes ARRAY<STRING>, count INT, started_at TIMESTAMP, won_games_at ARRAY<TIMESTAMP>, was_shortened BOOLEAN, players_nested ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>, players_object ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>>>,
110-
seasons_object ARRAY<STRUCT<the_record STRUCT<win_count INT, loss_count INT, last_win_date DATE, first_win_on DATE>, year INT, notes ARRAY<STRING>, count INT, started_at TIMESTAMP, won_games_at ARRAY<TIMESTAMP>, was_shortened BOOLEAN, players_nested ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>, players_object ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>>>,
111-
the_nested_fields STRUCT<forbes_valuation_moneys ARRAY<STRUCT<currency STRING, amount_cents INT>>, current_players ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>, the_seasons ARRAY<STRUCT<the_record STRUCT<win_count INT, loss_count INT, last_win_date DATE, first_win_on DATE>, year INT, notes ARRAY<STRING>, count INT, started_at TIMESTAMP, won_games_at ARRAY<TIMESTAMP>, was_shortened BOOLEAN, players_nested ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>, players_object ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>>>>,
112-
nested_fields2 STRUCT<forbes_valuation_moneys ARRAY<STRUCT<currency STRING, amount_cents INT>>, current_players ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>, the_seasons ARRAY<STRUCT<the_record STRUCT<win_count INT, loss_count INT, last_win_date DATE, first_win_on DATE>, year INT, notes ARRAY<STRING>, count INT, started_at TIMESTAMP, won_games_at ARRAY<TIMESTAMP>, was_shortened BOOLEAN, players_nested ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>, players_object ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>>>>,
109+
seasons_nested ARRAY<STRUCT<the_record STRUCT<win_count INT, loss_count INT, last_win_date DATE, first_win_on DATE>, year INT, notes ARRAY<STRING>, count INT, started_at TIMESTAMP, won_games_at ARRAY<TIMESTAMP>, was_shortened BOOLEAN, stadium_location STRUCT<lat FLOAT, lon FLOAT>, players_nested ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>, players_object ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>>>,
110+
seasons_object ARRAY<STRUCT<the_record STRUCT<win_count INT, loss_count INT, last_win_date DATE, first_win_on DATE>, year INT, notes ARRAY<STRING>, count INT, started_at TIMESTAMP, won_games_at ARRAY<TIMESTAMP>, was_shortened BOOLEAN, stadium_location STRUCT<lat FLOAT, lon FLOAT>, players_nested ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>, players_object ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>>>,
111+
the_nested_fields STRUCT<forbes_valuation_moneys ARRAY<STRUCT<currency STRING, amount_cents INT>>, current_players ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>, the_seasons ARRAY<STRUCT<the_record STRUCT<win_count INT, loss_count INT, last_win_date DATE, first_win_on DATE>, year INT, notes ARRAY<STRING>, count INT, started_at TIMESTAMP, won_games_at ARRAY<TIMESTAMP>, was_shortened BOOLEAN, stadium_location STRUCT<lat FLOAT, lon FLOAT>, players_nested ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>, players_object ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>>>>,
112+
nested_fields2 STRUCT<forbes_valuation_moneys ARRAY<STRUCT<currency STRING, amount_cents INT>>, current_players ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>, the_seasons ARRAY<STRUCT<the_record STRUCT<win_count INT, loss_count INT, last_win_date DATE, first_win_on DATE>, year INT, notes ARRAY<STRING>, count INT, started_at TIMESTAMP, won_games_at ARRAY<TIMESTAMP>, was_shortened BOOLEAN, stadium_location STRUCT<lat FLOAT, lon FLOAT>, players_nested ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>, players_object ARRAY<STRUCT<name STRING, nicknames ARRAY<STRING>, affiliations STRUCT<sponsorships_nested ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>, sponsorships_object ARRAY<STRUCT<sponsor_id STRING, annual_total STRUCT<currency STRING, amount_cents INT>>>>, seasons_nested ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>, seasons_object ARRAY<STRUCT<year INT, games_played INT, awards ARRAY<STRING>>>>>>>>,
113113
staff STRUCT<coaches ARRAY<STRUCT<id STRING, name STRING, salary INT>>, general_manager STRUCT<id STRING, name STRING, salary INT>>
114114
)
115115
widget_currencies:

‎config/schema/artifacts/datastore_config.yaml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ index_templates:
215215
format: strict_date_time
216216
was_shortened:
217217
type: boolean
218+
stadium_location:
219+
type: geo_point
218220
players_nested:
219221
properties:
220222
name:
@@ -414,6 +416,8 @@ index_templates:
414416
format: strict_date_time
415417
was_shortened:
416418
type: boolean
419+
stadium_location:
420+
type: geo_point
417421
players_nested:
418422
properties:
419423
name:
@@ -663,6 +667,8 @@ index_templates:
663667
format: strict_date_time
664668
was_shortened:
665669
type: boolean
670+
stadium_location:
671+
type: geo_point
666672
players_nested:
667673
properties:
668674
name:
@@ -950,6 +956,8 @@ index_templates:
950956
format: strict_date_time
951957
was_shortened:
952958
type: boolean
959+
stadium_location:
960+
type: geo_point
953961
players_nested:
954962
properties:
955963
name:
@@ -1216,6 +1224,12 @@ index_templates:
12161224
type: integer
12171225
seasons_object|was_shortened:
12181226
type: integer
1227+
seasons_object|stadium_location:
1228+
type: integer
1229+
seasons_object|stadium_location|lat:
1230+
type: integer
1231+
seasons_object|stadium_location|lon:
1232+
type: integer
12191233
seasons_object|players_nested:
12201234
type: integer
12211235
seasons_object|players_object:

‎config/schema/artifacts/json_schemas.yaml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,10 @@ json_schema_version: 1
10681068
anyOf:
10691069
- "$ref": "#/$defs/Boolean"
10701070
- type: 'null'
1071+
stadium_location:
1072+
anyOf:
1073+
- "$ref": "#/$defs/GeoLocation"
1074+
- type: 'null'
10711075
players_nested:
10721076
type: array
10731077
items:
@@ -1088,6 +1092,7 @@ json_schema_version: 1
10881092
- started_at
10891093
- won_games_at
10901094
- was_shortened
1095+
- stadium_location
10911096
- players_nested
10921097
- players_object
10931098
Untyped:

‎config/schema/artifacts/json_schemas_by_version/v1.yaml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,13 @@ json_schema_version: 1
14371437
ElasticGraph:
14381438
type: Boolean
14391439
nameInIndex: was_shortened
1440+
stadium_location:
1441+
anyOf:
1442+
- "$ref": "#/$defs/GeoLocation"
1443+
- type: 'null'
1444+
ElasticGraph:
1445+
type: GeoLocation
1446+
nameInIndex: stadium_location
14401447
players_nested:
14411448
type: array
14421449
items:
@@ -1463,6 +1470,7 @@ json_schema_version: 1
14631470
- started_at
14641471
- won_games_at
14651472
- was_shortened
1473+
- stadium_location
14661474
- players_nested
14671475
- players_object
14681476
Untyped:

0 commit comments

Comments
 (0)