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

Support Spatial Search in ES|QL (ST_INTERSECTS, ST_CONTAINS, ST_WITHIN and ST_DISJOINT) #104874

Closed
9 tasks done
craigtaverner opened this issue Jan 29, 2024 · 2 comments · Fixed by #104907, #107007, #106992 or #106503
Closed
9 tasks done
Assignees
Labels
:Analytics/ES|QL AKA ESQL :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 Jan 29, 2024

Description

The spatial search in Elasticsearch is directly backed by Lucene for four cases:

  • Intersects
  • Contains
  • Within
  • Disjoint

These can be exposed in ES|QL through four OGC compliant functions:

  • boolean ST_INTERSECTS(geomA, geomB)
  • boolean ST_CONTAINS(geomA, geomB)
  • boolean ST_WITHIN(geomA, geomB)
  • boolean ST_DISJOINT(geomA, geomB)

For example:

FROM airports
| EVAL polygon = TO_GEOSHAPE("POLYGON((...))")
| WHERE ST_INTERSECTS(location, polygon)

See the PostGIS documentation for inspiration: https://postgis.net/docs/ST_Intersects.html

The feature can be developed in several phases:

  • Bring back Intersects prototype prototype from last summer
    • Expects constant string WKT
    • Does in-memory constant->triangle-tree and then internal intersects
  • Support all kinds of fields (source, doc-values, constants, geo/cartesian, point/shape)
  • LocalPhysicalPlanner support for push-down to Lucene
    • Handle special cases regarding cartesian data (not fully supported in Elasticsearch)

Tasks

@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) :Analytics/ES|QL AKA ESQL labels Jan 29, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@nik9000
Copy link
Member

nik9000 commented Jan 30, 2024

At least they all start with ST_!

@craigtaverner craigtaverner changed the title Support ST_INTERSECTS in ES|QL Support Spatial Search in ES|QL (ST_INTERSECTS, ST_CONTAINS, ST_WITHIN and ST_DISJOINT) Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment