diff --git a/docs/reference/query-languages/esql/_snippets/functions/description/st_geohash.md b/docs/reference/query-languages/esql/_snippets/functions/description/st_geohash.md index 9531779bca629..877a49d6a86b7 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/description/st_geohash.md +++ b/docs/reference/query-languages/esql/_snippets/functions/description/st_geohash.md @@ -2,5 +2,5 @@ **Description** -Calculates the `geohash` of the supplied geo_point at the specified precision. The result is long encoded. Use [TO_STRING](#esql-to_string) to convert the result to a string, [TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](esql-to_geoshape.md) to calculate the `geo_shape` bounding geometry. These functions are related to the [`geo_grid` query](/reference/query-languages/query-dsl/query-dsl-geo-grid-query.md) and the [`geohash_grid` aggregation](/reference/aggregations/search-aggregations-bucket-geohashgrid-aggregation.md). +Calculates the `geohash` of the supplied geo_point at the specified precision. The result is long encoded. Use [TO_STRING](#esql-to_string) to convert the result to a string, [TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](#esql-to_geoshape) to calculate the `geo_shape` bounding geometry. These functions are related to the [`geo_grid` query](/reference/query-languages/query-dsl/query-dsl-geo-grid-query.md) and the [`geohash_grid` aggregation](/reference/aggregations/search-aggregations-bucket-geohashgrid-aggregation.md). diff --git a/docs/reference/query-languages/esql/_snippets/functions/description/st_geohex.md b/docs/reference/query-languages/esql/_snippets/functions/description/st_geohex.md index e240d28f6d0b0..73f87ee573eb1 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/description/st_geohex.md +++ b/docs/reference/query-languages/esql/_snippets/functions/description/st_geohex.md @@ -2,5 +2,5 @@ **Description** -Calculates the `geohex`, the H3 cell-id, of the supplied geo_point at the specified precision. The result is long encoded. Use [TO_STRING](#esql-to_string) to convert the result to a string, [TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](esql-to_geoshape.md) to calculate the `geo_shape` bounding geometry. These functions are related to the [`geo_grid` query](/reference/query-languages/query-dsl/query-dsl-geo-grid-query.md) and the [`geohex_grid` aggregation](/reference/aggregations/search-aggregations-bucket-geohexgrid-aggregation.md). +Calculates the `geohex`, the H3 cell-id, of the supplied geo_point at the specified precision. The result is long encoded. Use [TO_STRING](#esql-to_string) to convert the result to a string, [TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](#esql-to_geoshape) to calculate the `geo_shape` bounding geometry. These functions are related to the [`geo_grid` query](/reference/query-languages/query-dsl/query-dsl-geo-grid-query.md) and the [`geohex_grid` aggregation](/reference/aggregations/search-aggregations-bucket-geohexgrid-aggregation.md). diff --git a/docs/reference/query-languages/esql/_snippets/functions/description/st_geotile.md b/docs/reference/query-languages/esql/_snippets/functions/description/st_geotile.md index 36c1875196b2f..2b417b682c6a8 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/description/st_geotile.md +++ b/docs/reference/query-languages/esql/_snippets/functions/description/st_geotile.md @@ -2,5 +2,5 @@ **Description** -Calculates the `geotile` of the supplied geo_point at the specified precision. The result is long encoded. Use [TO_STRING](#esql-to_string) to convert the result to a string, [TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](esql-to_geoshape.md) to calculate the `geo_shape` bounding geometry. These functions are related to the [`geo_grid` query](/reference/query-languages/query-dsl/query-dsl-geo-grid-query.md) and the [`geotile_grid` aggregation](/reference/aggregations/search-aggregations-bucket-geotilegrid-aggregation.md). +Calculates the `geotile` of the supplied geo_point at the specified precision. The result is long encoded. Use [TO_STRING](#esql-to_string) to convert the result to a string, [TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](#esql-to_geoshape) to calculate the `geo_shape` bounding geometry. These functions are related to the [`geo_grid` query](/reference/query-languages/query-dsl/query-dsl-geo-grid-query.md) and the [`geotile_grid` aggregation](/reference/aggregations/search-aggregations-bucket-geotilegrid-aggregation.md). diff --git a/docs/reference/query-languages/esql/_snippets/functions/description/to_geohash.md b/docs/reference/query-languages/esql/_snippets/functions/description/to_geohash.md index 0c588cfc2a876..2648dcdc5fecd 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/description/to_geohash.md +++ b/docs/reference/query-languages/esql/_snippets/functions/description/to_geohash.md @@ -2,5 +2,5 @@ **Description** -Converts an input value to a `geohash` value. A string will only be successfully converted if it respects the `geohash` format. +Converts an input value to a `geohash` value. A string will only be successfully converted if it respects the `geohash` format, as described for the [geohash grid aggregation](/reference/aggregations/search-aggregations-bucket-geohashgrid-aggregation.md). diff --git a/docs/reference/query-languages/esql/_snippets/functions/description/to_geohex.md b/docs/reference/query-languages/esql/_snippets/functions/description/to_geohex.md index 78eaa369454ca..7d458146281b6 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/description/to_geohex.md +++ b/docs/reference/query-languages/esql/_snippets/functions/description/to_geohex.md @@ -2,5 +2,5 @@ **Description** -Converts an input value to a `geohex` value. A string will only be successfully converted if it respects the `geohex` format. +Converts an input value to a `geohex` value. A string will only be successfully converted if it respects the `geohex` format, as described for the [geohex grid aggregation](/reference/aggregations/search-aggregations-bucket-geohexgrid-aggregation.md). diff --git a/docs/reference/query-languages/esql/_snippets/functions/description/to_geotile.md b/docs/reference/query-languages/esql/_snippets/functions/description/to_geotile.md index b5a2c3812e254..7137969e55c83 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/description/to_geotile.md +++ b/docs/reference/query-languages/esql/_snippets/functions/description/to_geotile.md @@ -2,5 +2,5 @@ **Description** -Converts an input value to a `geotile` value. A string will only be successfully converted if it respects the `geotile` format. +Converts an input value to a `geotile` value. A string will only be successfully converted if it respects the `geotile` format, as described for the [geotile grid aggregation](/reference/aggregations/search-aggregations-bucket-geotilegrid-aggregation.md). diff --git a/docs/reference/query-languages/esql/_snippets/lists/spatial-functions.md b/docs/reference/query-languages/esql/_snippets/lists/spatial-functions.md index 83cfdd4c60867..9a0718b44a1b3 100644 --- a/docs/reference/query-languages/esql/_snippets/lists/spatial-functions.md +++ b/docs/reference/query-languages/esql/_snippets/lists/spatial-functions.md @@ -10,3 +10,6 @@ * [preview] [`ST_XMIN`](../../functions-operators/spatial-functions.md#esql-st_xmin) * [preview] [`ST_YMAX`](../../functions-operators/spatial-functions.md#esql-st_ymax) * [preview] [`ST_YMIN`](../../functions-operators/spatial-functions.md#esql-st_ymin) +* [preview] [`ST_GEOTILE`](../../functions-operators/spatial-functions.md#esql-st_geotile) +* [preview] [`ST_GEOHEX`](../../functions-operators/spatial-functions.md#esql-st_geohex) +* [preview] [`ST_GEOHASH`](../../functions-operators/spatial-functions.md#esql-st_geohash) diff --git a/docs/reference/query-languages/esql/_snippets/lists/type-conversion-functions.md b/docs/reference/query-languages/esql/_snippets/lists/type-conversion-functions.md index 8867386f00a2d..5b26037a59d0d 100644 --- a/docs/reference/query-languages/esql/_snippets/lists/type-conversion-functions.md +++ b/docs/reference/query-languages/esql/_snippets/lists/type-conversion-functions.md @@ -6,8 +6,11 @@ * [`TO_DATE_NANOS`](../../functions-operators/type-conversion-functions.md#esql-to_date_nanos) * [`TO_DEGREES`](../../functions-operators/type-conversion-functions.md#esql-to_degrees) * [`TO_DOUBLE`](../../functions-operators/type-conversion-functions.md#esql-to_double) +* [preview] [`TO_GEOHASH`](../../functions-operators/type-conversion-functions.md#esql-to_geohash) +* [preview] [`TO_GEOHEX`](../../functions-operators/type-conversion-functions.md#esql-to_geohex) * [`TO_GEOPOINT`](../../functions-operators/type-conversion-functions.md#esql-to_geopoint) * [`TO_GEOSHAPE`](../../functions-operators/type-conversion-functions.md#esql-to_geoshape) +* [preview] [`TO_GEOTILE`](../../functions-operators/type-conversion-functions.md#esql-to_geotile) * [`TO_INTEGER`](../../functions-operators/type-conversion-functions.md#esql-to_integer) * [`TO_IP`](../../functions-operators/type-conversion-functions.md#esql-to_ip) * [`TO_LONG`](../../functions-operators/type-conversion-functions.md#esql-to_long) diff --git a/docs/reference/query-languages/esql/functions-operators/spatial-functions.md b/docs/reference/query-languages/esql/functions-operators/spatial-functions.md index 60746205e60e4..6f180b4f02b47 100644 --- a/docs/reference/query-languages/esql/functions-operators/spatial-functions.md +++ b/docs/reference/query-languages/esql/functions-operators/spatial-functions.md @@ -47,3 +47,12 @@ mapped_pages: :::{include} ../_snippets/functions/layout/st_ymin.md ::: + +:::{include} ../_snippets/functions/layout/st_geotile.md +::: + +:::{include} ../_snippets/functions/layout/st_geohex.md +::: + +:::{include} ../_snippets/functions/layout/st_geohash.md +::: diff --git a/docs/reference/query-languages/esql/functions-operators/type-conversion-functions.md b/docs/reference/query-languages/esql/functions-operators/type-conversion-functions.md index 246bb4b5fa30f..653f1a9373848 100644 --- a/docs/reference/query-languages/esql/functions-operators/type-conversion-functions.md +++ b/docs/reference/query-languages/esql/functions-operators/type-conversion-functions.md @@ -43,12 +43,21 @@ mapped_pages: :::{include} ../_snippets/functions/layout/to_double.md ::: +:::{include} ../_snippets/functions/layout/to_geohash.md +::: + +:::{include} ../_snippets/functions/layout/to_geohex.md +::: + :::{include} ../_snippets/functions/layout/to_geopoint.md ::: :::{include} ../_snippets/functions/layout/to_geoshape.md ::: +:::{include} ../_snippets/functions/layout/to_geotile.md +::: + :::{include} ../_snippets/functions/layout/to_integer.md ::: diff --git a/docs/reference/query-languages/esql/kibana/definition/functions/st_geohash.json b/docs/reference/query-languages/esql/kibana/definition/functions/st_geohash.json index 509ac4b776afe..369e20eedf5f8 100644 --- a/docs/reference/query-languages/esql/kibana/definition/functions/st_geohash.json +++ b/docs/reference/query-languages/esql/kibana/definition/functions/st_geohash.json @@ -51,5 +51,5 @@ "FROM airports\n| EVAL geohash = ST_GEOHASH(location, 1)\n| STATS\n count = COUNT(geohash),\n centroid = ST_CENTROID_AGG(location)\n BY geohash\n| WHERE count >= 10\n| EVAL geohashString = TO_STRING(geohash)\n| KEEP count, centroid, geohashString\n| SORT count DESC, geohashString ASC" ], "preview" : true, - "snapshot_only" : true + "snapshot_only" : false } diff --git a/docs/reference/query-languages/esql/kibana/definition/functions/st_geohex.json b/docs/reference/query-languages/esql/kibana/definition/functions/st_geohex.json index 019fe27405f51..edf1d966685e6 100644 --- a/docs/reference/query-languages/esql/kibana/definition/functions/st_geohex.json +++ b/docs/reference/query-languages/esql/kibana/definition/functions/st_geohex.json @@ -54,5 +54,5 @@ "FROM airports\n| EVAL geohex = ST_GEOHEX(location, 1)\n| STATS\n count = COUNT(geohex),\n centroid = ST_CENTROID_AGG(location)\n BY geohex\n| WHERE count >= 10\n| EVAL geohexString = TO_STRING(geohex)\n| KEEP count, centroid, geohexString\n| SORT count DESC, geohexString ASC" ], "preview" : true, - "snapshot_only" : true + "snapshot_only" : false } diff --git a/docs/reference/query-languages/esql/kibana/definition/functions/st_geotile.json b/docs/reference/query-languages/esql/kibana/definition/functions/st_geotile.json index bd5fb4ede8cc4..f3a1f0abf95ee 100644 --- a/docs/reference/query-languages/esql/kibana/definition/functions/st_geotile.json +++ b/docs/reference/query-languages/esql/kibana/definition/functions/st_geotile.json @@ -51,5 +51,5 @@ "FROM airports\n| EVAL geotile = ST_GEOTILE(location, 2)\n| STATS\n count = COUNT(geotile),\n centroid = ST_CENTROID_AGG(location)\n BY geotile\n| EVAL geotileString = TO_STRING(geotile)\n| SORT count DESC, geotileString ASC\n| KEEP count, centroid, geotileString" ], "preview" : true, - "snapshot_only" : true + "snapshot_only" : false } diff --git a/docs/reference/query-languages/esql/kibana/definition/functions/to_geohash.json b/docs/reference/query-languages/esql/kibana/definition/functions/to_geohash.json index 9c6645f19f2eb..317716ece4db3 100644 --- a/docs/reference/query-languages/esql/kibana/definition/functions/to_geohash.json +++ b/docs/reference/query-languages/esql/kibana/definition/functions/to_geohash.json @@ -2,7 +2,7 @@ "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it.", "type" : "scalar", "name" : "to_geohash", - "description" : "Converts an input value to a `geohash` value.\nA string will only be successfully converted if it respects the\n`geohash` format.", + "description" : "Converts an input value to a `geohash` value.\nA string will only be successfully converted if it respects the\n`geohash` format, as described for the\ngeohash grid aggregation.", "signatures" : [ { "params" : [ @@ -57,5 +57,5 @@ "ROW string = \"u3bu\"\n| EVAL geohash = TO_GEOHASH(string)" ], "preview" : true, - "snapshot_only" : true + "snapshot_only" : false } diff --git a/docs/reference/query-languages/esql/kibana/definition/functions/to_geohex.json b/docs/reference/query-languages/esql/kibana/definition/functions/to_geohex.json index 9d75a0d5db755..0949e9d929882 100644 --- a/docs/reference/query-languages/esql/kibana/definition/functions/to_geohex.json +++ b/docs/reference/query-languages/esql/kibana/definition/functions/to_geohex.json @@ -2,7 +2,7 @@ "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it.", "type" : "scalar", "name" : "to_geohex", - "description" : "Converts an input value to a `geohex` value.\nA string will only be successfully converted if it respects the\n`geohex` format.", + "description" : "Converts an input value to a `geohex` value.\nA string will only be successfully converted if it respects the\n`geohex` format, as described for the\ngeohex grid aggregation.", "signatures" : [ { "params" : [ @@ -57,5 +57,5 @@ "ROW string = \"841f059ffffffff\"\n| EVAL geohex = TO_GEOHEX(string)" ], "preview" : true, - "snapshot_only" : true + "snapshot_only" : false } diff --git a/docs/reference/query-languages/esql/kibana/definition/functions/to_geotile.json b/docs/reference/query-languages/esql/kibana/definition/functions/to_geotile.json index 85879c996dad7..a5b7150326b40 100644 --- a/docs/reference/query-languages/esql/kibana/definition/functions/to_geotile.json +++ b/docs/reference/query-languages/esql/kibana/definition/functions/to_geotile.json @@ -2,7 +2,7 @@ "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it.", "type" : "scalar", "name" : "to_geotile", - "description" : "Converts an input value to a `geotile` value.\nA string will only be successfully converted if it respects the\n`geotile` format.", + "description" : "Converts an input value to a `geotile` value.\nA string will only be successfully converted if it respects the\n`geotile` format, as described for the\ngeotile grid aggregation.", "signatures" : [ { "params" : [ @@ -57,5 +57,5 @@ "ROW string = \"4/8/5\"\n| EVAL geotile = TO_GEOTILE(string)" ], "preview" : true, - "snapshot_only" : true + "snapshot_only" : false } diff --git a/docs/reference/query-languages/esql/kibana/docs/functions/st_geohash.md b/docs/reference/query-languages/esql/kibana/docs/functions/st_geohash.md index 17d0c71f274b2..0db9ab65bf325 100644 --- a/docs/reference/query-languages/esql/kibana/docs/functions/st_geohash.md +++ b/docs/reference/query-languages/esql/kibana/docs/functions/st_geohash.md @@ -3,7 +3,7 @@ ### ST GEOHASH Calculates the `geohash` of the supplied geo_point at the specified precision. The result is long encoded. Use [TO_STRING](#esql-to_string) to convert the result to a string, -[TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](esql-to_geoshape.md) to calculate +[TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](#esql-to_geoshape) to calculate the `geo_shape` bounding geometry. These functions are related to the [`geo_grid` query](https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-geo-grid-query) diff --git a/docs/reference/query-languages/esql/kibana/docs/functions/st_geohex.md b/docs/reference/query-languages/esql/kibana/docs/functions/st_geohex.md index 02143698b7b6c..c2d071daa9241 100644 --- a/docs/reference/query-languages/esql/kibana/docs/functions/st_geohex.md +++ b/docs/reference/query-languages/esql/kibana/docs/functions/st_geohex.md @@ -3,7 +3,7 @@ ### ST GEOHEX Calculates the `geohex`, the H3 cell-id, of the supplied geo_point at the specified precision. The result is long encoded. Use [TO_STRING](#esql-to_string) to convert the result to a string, -[TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](esql-to_geoshape.md) to calculate +[TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](#esql-to_geoshape) to calculate the `geo_shape` bounding geometry. These functions are related to the [`geo_grid` query](https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-geo-grid-query) diff --git a/docs/reference/query-languages/esql/kibana/docs/functions/st_geotile.md b/docs/reference/query-languages/esql/kibana/docs/functions/st_geotile.md index 236a68e66d374..4195a044e2d12 100644 --- a/docs/reference/query-languages/esql/kibana/docs/functions/st_geotile.md +++ b/docs/reference/query-languages/esql/kibana/docs/functions/st_geotile.md @@ -3,7 +3,7 @@ ### ST GEOTILE Calculates the `geotile` of the supplied geo_point at the specified precision. The result is long encoded. Use [TO_STRING](#esql-to_string) to convert the result to a string, -[TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](esql-to_geoshape.md) to calculate +[TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](#esql-to_geoshape) to calculate the `geo_shape` bounding geometry. These functions are related to the [`geo_grid` query](https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-geo-grid-query) diff --git a/docs/reference/query-languages/esql/kibana/docs/functions/to_geohash.md b/docs/reference/query-languages/esql/kibana/docs/functions/to_geohash.md index 59277639cf6f3..2c57afc95e317 100644 --- a/docs/reference/query-languages/esql/kibana/docs/functions/to_geohash.md +++ b/docs/reference/query-languages/esql/kibana/docs/functions/to_geohash.md @@ -3,7 +3,8 @@ ### TO GEOHASH Converts an input value to a `geohash` value. A string will only be successfully converted if it respects the -`geohash` format. +`geohash` format, as described for the +[geohash grid aggregation](https://www.elastic.co/docs/reference/aggregations/search-aggregations-bucket-geohashgrid-aggregation). ```esql ROW string = "u3bu" diff --git a/docs/reference/query-languages/esql/kibana/docs/functions/to_geohex.md b/docs/reference/query-languages/esql/kibana/docs/functions/to_geohex.md index 1d6e3b968995e..bf53d13e7c8f9 100644 --- a/docs/reference/query-languages/esql/kibana/docs/functions/to_geohex.md +++ b/docs/reference/query-languages/esql/kibana/docs/functions/to_geohex.md @@ -3,7 +3,8 @@ ### TO GEOHEX Converts an input value to a `geohex` value. A string will only be successfully converted if it respects the -`geohex` format. +`geohex` format, as described for the +[geohex grid aggregation](https://www.elastic.co/docs/reference/aggregations/search-aggregations-bucket-geohexgrid-aggregation). ```esql ROW string = "841f059ffffffff" diff --git a/docs/reference/query-languages/esql/kibana/docs/functions/to_geotile.md b/docs/reference/query-languages/esql/kibana/docs/functions/to_geotile.md index a123797d01d7b..9730dc8c7a3ad 100644 --- a/docs/reference/query-languages/esql/kibana/docs/functions/to_geotile.md +++ b/docs/reference/query-languages/esql/kibana/docs/functions/to_geotile.md @@ -3,7 +3,8 @@ ### TO GEOTILE Converts an input value to a `geotile` value. A string will only be successfully converted if it respects the -`geotile` format. +`geotile` format, as described for the +[geotile grid aggregation](https://www.elastic.co/docs/reference/aggregations/search-aggregations-bucket-geotilegrid-aggregation). ```esql ROW string = "4/8/5" diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/spatial/SpatialGridLicenseTestCase.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/spatial/SpatialGridLicenseTestCase.java index e7297f49f0cea..d1db4de058411 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/spatial/SpatialGridLicenseTestCase.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/spatial/SpatialGridLicenseTestCase.java @@ -61,10 +61,10 @@ protected int precision() { } /** - * Test that the geo_grid functions are disabled outside of SNAPSHOT. + * Test that the geo_grid functions are enabled outside of SNAPSHOT. */ - public void testGeoGridDisabled() { - assertGeoGridDisabledWith("index_geo_point"); + public void testGeoGridEnabled() { + assertGeoGridEnabled(); } /** @@ -120,16 +120,10 @@ protected void assertGeoGridFailsWith(String index) { assertThat(e.getMessage(), containsString(expectedError)); } - protected void assertGeoGridDisabledWith(String index) { - assumeFalse("testing feature is disabled in non-snapshot builds", Build.current().isSnapshot()); - var query = String.format(Locale.ROOT, """ - FROM %s - | EVAL gridId = %s(location, %d) - | STATS count=COUNT() BY gridId - """, index, gridFunction(), precision()); - var expectedError = String.format(Locale.ROOT, "Unknown function [%s]", gridFunction()); - ElasticsearchException e = expectThrows(VerificationException.class, () -> run(query)); - assertThat(e.getMessage(), containsString(expectedError)); + protected void assertGeoGridEnabled() { + assumeFalse("testing feature is enabled in non-snapshot builds", Build.current().isSnapshot()); + assertThat("Capability SPATIAL_GRID_TYPES should be enabled", EsqlCapabilities.Cap.SPATIAL_GRID_TYPES.isEnabled(), equalTo(true)); + testGeoGridWithPoints(); } public static Map getValuesMap(Iterator> values) { diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java index ffa28db2fa7af..3f921b33fd88a 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java @@ -414,17 +414,17 @@ public enum Cap { /** * Support ST_GEOHASH, ST_GEOTILE and ST_GEOHEX functions */ - SPATIAL_GRID(Build.current().isSnapshot()), + SPATIAL_GRID, /** * Support geohash, geotile and geohex data types. Done in #129581 */ - SPATIAL_GRID_TYPES(Build.current().isSnapshot()), + SPATIAL_GRID_TYPES, /** * Support geohash, geotile and geohex in ST_INTERSECTS and ST_DISJOINT. Done in #133546 */ - SPATIAL_GRID_INTERSECTS(Build.current().isSnapshot()), + SPATIAL_GRID_INTERSECTS, /** * Fix to GROK and DISSECT that allows extracting attributes with the same name as the input diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java index c94d93c0e9be8..ab570e4833fb4 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java @@ -422,6 +422,9 @@ private static FunctionDefinition[][] functions() { def(SpatialWithin.class, SpatialWithin::new, "st_within"), def(StDistance.class, StDistance::new, "st_distance"), def(StEnvelope.class, StEnvelope::new, "st_envelope"), + def(StGeohash.class, StGeohash::new, "st_geohash"), + def(StGeotile.class, StGeotile::new, "st_geotile"), + def(StGeohex.class, StGeohex::new, "st_geohex"), def(StXMax.class, StXMax::new, "st_xmax"), def(StXMin.class, StXMin::new, "st_xmin"), def(StYMax.class, StYMax::new, "st_ymax"), @@ -448,6 +451,9 @@ private static FunctionDefinition[][] functions() { def(ToDateNanos.class, ToDateNanos::new, "to_date_nanos", "to_datenanos"), def(ToDegrees.class, ToDegrees::new, "to_degrees"), def(ToDouble.class, ToDouble::new, "to_double", "to_dbl"), + def(ToGeohash.class, ToGeohash::new, "to_geohash"), + def(ToGeotile.class, ToGeotile::new, "to_geotile"), + def(ToGeohex.class, ToGeohex::new, "to_geohex"), def(ToGeoPoint.class, ToGeoPoint::new, "to_geopoint"), def(ToGeoShape.class, ToGeoShape::new, "to_geoshape"), def(ToIp.class, ToIp::new, "to_ip"), @@ -510,12 +516,6 @@ private static FunctionDefinition[][] snapshotFunctions() { def(Score.class, uni(Score::new), Score.NAME), def(Term.class, bi(Term::new), "term"), def(Knn.class, tri(Knn::new), "knn"), - def(ToGeohash.class, ToGeohash::new, "to_geohash"), - def(ToGeotile.class, ToGeotile::new, "to_geotile"), - def(ToGeohex.class, ToGeohex::new, "to_geohex"), - def(StGeohash.class, StGeohash::new, "st_geohash"), - def(StGeotile.class, StGeotile::new, "st_geotile"), - def(StGeohex.class, StGeohex::new, "st_geohex"), def(CosineSimilarity.class, CosineSimilarity::new, "v_cosine"), def(DotProduct.class, DotProduct::new, "v_dot_product"), def(L1Norm.class, L1Norm::new, "v_l1_norm"), diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToGeohash.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToGeohash.java index 0ea490098ca6f..fef2a691c6e1a 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToGeohash.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToGeohash.java @@ -52,7 +52,8 @@ public class ToGeohash extends AbstractConvertFunction { description = """ Converts an input value to a `geohash` value. A string will only be successfully converted if it respects the - `geohash` format.""", + `geohash` format, as described for the + [geohash grid aggregation](/reference/aggregations/search-aggregations-bucket-geohashgrid-aggregation.md).""", examples = @Example(file = "spatial-grid", tag = "to_geohash") ) public ToGeohash( diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToGeohex.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToGeohex.java index 4ccda5cea66f8..77becb1f96f9d 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToGeohex.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToGeohex.java @@ -48,7 +48,8 @@ public class ToGeohex extends AbstractConvertFunction { description = """ Converts an input value to a `geohex` value. A string will only be successfully converted if it respects the - `geohex` format.""", + `geohex` format, as described for the + [geohex grid aggregation](/reference/aggregations/search-aggregations-bucket-geohexgrid-aggregation.md).""", examples = @Example(file = "spatial-grid", tag = "to_geohex") ) public ToGeohex( diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToGeotile.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToGeotile.java index ea2c3075a9303..fc31b574ab03f 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToGeotile.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToGeotile.java @@ -52,7 +52,8 @@ public class ToGeotile extends AbstractConvertFunction { description = """ Converts an input value to a `geotile` value. A string will only be successfully converted if it respects the - `geotile` format.""", + `geotile` format, as described for the + [geotile grid aggregation](/reference/aggregations/search-aggregations-bucket-geotilegrid-aggregation.md).""", examples = @Example(file = "spatial-grid", tag = "to_geotile") ) public ToGeotile( diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeohash.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeohash.java index 02994ea2ae550..b1fffe95b9b23 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeohash.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeohash.java @@ -118,7 +118,7 @@ private static int checkPrecisionRange(int precision) { description = """ Calculates the `geohash` of the supplied geo_point at the specified precision. The result is long encoded. Use [TO_STRING](#esql-to_string) to convert the result to a string, - [TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](esql-to_geoshape.md) to calculate + [TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](#esql-to_geoshape) to calculate the `geo_shape` bounding geometry. These functions are related to the [`geo_grid` query](/reference/query-languages/query-dsl/query-dsl-geo-grid-query.md) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeohex.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeohex.java index b595d92007ef1..2315af2e2cbe9 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeohex.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeohex.java @@ -119,7 +119,7 @@ private static int checkPrecisionRange(int precision) { description = """ Calculates the `geohex`, the H3 cell-id, of the supplied geo_point at the specified precision. The result is long encoded. Use [TO_STRING](#esql-to_string) to convert the result to a string, - [TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](esql-to_geoshape.md) to calculate + [TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](#esql-to_geoshape) to calculate the `geo_shape` bounding geometry. These functions are related to the [`geo_grid` query](/reference/query-languages/query-dsl/query-dsl-geo-grid-query.md) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeotile.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeotile.java index b86d121c0c961..25264d696f731 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeotile.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StGeotile.java @@ -115,7 +115,7 @@ public GeoTileBoundedGrid get(DriverContext context) { description = """ Calculates the `geotile` of the supplied geo_point at the specified precision. The result is long encoded. Use [TO_STRING](#esql-to_string) to convert the result to a string, - [TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](esql-to_geoshape.md) to calculate + [TO_LONG](#esql-to_long) to convert it to a `long`, or [TO_GEOSHAPE](#esql-to_geoshape) to calculate the `geo_shape` bounding geometry. These functions are related to the [`geo_grid` query](/reference/query-languages/query-dsl/query-dsl-geo-grid-query.md) diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml index 670caf440f8d6..90eb44b36c17d 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml @@ -225,7 +225,7 @@ setup: - gt: {esql.functions.to_long: $functions_to_long} - match: {esql.functions.coalesce: $functions_coalesce} - gt: {esql.functions.categorize: $functions_categorize} - - length: {esql.functions: 144} # check the "sister" test above for a likely update to the same esql.functions length check + - length: {esql.functions: 150} # check the "sister" test above for a likely update to the same esql.functions length check --- took: