Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geohex grid aggregation on geo_shape MVP #90163

Closed
11 of 13 tasks
craigtaverner opened this issue Sep 20, 2022 · 1 comment
Closed
11 of 13 tasks

Geohex grid aggregation on geo_shape MVP #90163

craigtaverner opened this issue Sep 20, 2022 · 1 comment
Assignees
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@craigtaverner
Copy link
Contributor

craigtaverner commented Sep 20, 2022

Elasticsearch already [supports geohex grid aggregations|https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohexgrid-aggregation.html], but only on geo_point. There is value in supporting this on fields of type geo_shape too. Since the related [geotile|https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geotilegrid-aggregation.html] and [geohash|https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html] aggregations work with both geo_point and geoshapewe can apply similar thinking to thegeohex` aggregation.

The main challenge is that both geohash and geotile work with euclidean space (mercator projection) while geohex is very much more spherical. As a result the underlying maths needs to take this into account. The approach used by the existing geo_point support is to connect the existing 2D euclidean aggregation support (using Lucene's Component2D) to the underlying maths provided by Lucene's spatial3d library. Currently we support geo_point aggregations by implementing only a small part of the Component2D interface. Supporting geo_shape could require completing this support.

Update: This initial plan of using spatial3d for geohex over geo_shape was used in the prototype, but during that work we realised that polygons stored in elasticsearch are indexed with edges assumed to be lines in equirectangular projection. In order to ensure that aggregations match queries, we need to perform the aggregation in equirectangular projection too. Initially this was attempted in the prototype below, maintaining both spherical and equirectangular approaches in parallel. However, this proved to be unnecessarily complex, and performed badly (slow queries), so a new prototype was built with equirectangular-only and a focus on performance with dramatically improved results. This second attempt became the base of the production version.

h3. Sub-tasks:

h4. [Prototype|https://github.com//pull/90026]:

  • Complete Component2D support in the H3LatLonGeometry class
  • Unit tests of all new supporting code for this Component2D work
  • Create infrastructure for supporting geo_shape in geohex grid aggregations
  • Some basic test coverage
  • Discuss prototype learnings

h4. Make production ready

Marketing

  • Blog
  • Release notes
@craigtaverner craigtaverner self-assigned this Sep 20, 2022
@elasticsearchmachine elasticsearchmachine added the needs:triage Requires assignment of a team area label label Sep 20, 2022
@craigtaverner craigtaverner changed the title Geo hex grid aggregation on Shape Geohex grid aggregation on Shape Sep 20, 2022
@craigtaverner craigtaverner added >enhancement :Analytics/Geo Indexing, search aggregations of geo points and shapes Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) and removed needs:triage Requires assignment of a team area label labels Sep 20, 2022
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

@craigtaverner craigtaverner changed the title Geohex grid aggregation on Shape Geohex grid aggregation on geo_shape Nov 23, 2022
@exalate-issue-sync exalate-issue-sync bot changed the title Geohex grid aggregation on geo_shape Geohex grid aggregation on geo_shape MVP Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)
Projects
None yet
Development

No branches or pull requests

2 participants