Skip to content

Commit

Permalink
ESQL: Documentation for support for geo_point and point (elastic#103207)
Browse files Browse the repository at this point in the history
* Start working on geo_point and point docs for ESQL

* Added to_cartesianpoint and includes

* Sub-headings for easier reading

* Improve sub-headings

* Hide to_long and support for longs in to_geopoint and to_cartesianpoint
  • Loading branch information
craigtaverner authored Dec 12, 2023
1 parent c55495d commit e1835c9
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 10 deletions.
2 changes: 2 additions & 0 deletions docs/reference/esql/esql-functions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ include::functions/tan.asciidoc[]
include::functions/tanh.asciidoc[]
include::functions/tau.asciidoc[]
include::functions/to_boolean.asciidoc[]
include::functions/to_cartesianpoint.asciidoc[]
include::functions/to_datetime.asciidoc[]
include::functions/to_degrees.asciidoc[]
include::functions/to_double.asciidoc[]
include::functions/to_geopoint.asciidoc[]
include::functions/to_integer.asciidoc[]
include::functions/to_ip.asciidoc[]
include::functions/to_long.asciidoc[]
Expand Down
11 changes: 6 additions & 5 deletions docs/reference/esql/esql-limitations.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ include::processing-commands/limit.asciidoc[tag=limitation]
* `text`
* `unsigned_long`
* `version`
* Spatial types
** `geo_point`
** `point`

[discrete]
==== Unsupported types
Expand All @@ -44,10 +47,8 @@ include::processing-commands/limit.asciidoc[tag=limitation]
** `counter`
** `position`
** `aggregate_metric_double`
* Geo/spatial
** `geo_point`
* Spatial types
** `geo_shape`
** `point`
** `shape`
* Date/time
** `date_nanos`
Expand Down Expand Up @@ -119,7 +120,7 @@ consequences. An {esql} query on a `text` field is case-sensitive. Furthermore,
a subfield may have been mapped with a <<normalizer,normalizer>>, which can
transform the original string. Or it may have been mapped with <<ignore-above>>,
which can truncate the string. None of these mapping operations are applied to
an {esql} query, which may lead to false positives or negatives.
an {esql} query, which may lead to false positives or negatives.

To avoid these issues, a best practice is to be explicit about the field that
you query, and query `keyword` sub-fields instead of `text` fields.
Expand Down Expand Up @@ -197,4 +198,4 @@ the <<esql-mv-functions,multivalue functions>>.
[[esql-limitations-kibana]]
=== Kibana limitations

include::esql-kibana.asciidoc[tag=limitations]
include::esql-kibana.asciidoc[tag=limitations]
19 changes: 19 additions & 0 deletions docs/reference/esql/functions/to_cartesianpoint.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[discrete]
[[esql-to_cartesianpoint]]
=== `TO_CARTESIANPOINT`
Converts an input value to a `point` value.

The input can be a single- or multi-valued field or an expression.
The input type must be a string or a cartesian `point`.

A string will only be successfully converted if it respects the
https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry[WKT Point] format:

[source.merge.styled,esql]
----
include::{esql-specs}/spatial.csv-spec[tag=to_cartesianpoint-str]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/spatial.csv-spec[tag=to_cartesianpoint-str-result]
|===
19 changes: 19 additions & 0 deletions docs/reference/esql/functions/to_geopoint.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[discrete]
[[esql-to_geopoint]]
=== `TO_GEOPOINT`
Converts an input value to a `geo_point` value.

The input can be a single- or multi-valued field or an expression.
The input type must be a string or a `geo_point`.

A string will only be successfully converted if it respects the
https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry[WKT Point] format:

[source.merge.styled,esql]
----
include::{esql-specs}/spatial.csv-spec[tag=to_geopoint-str]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/spatial.csv-spec[tag=to_geopoint-str-result]
|===
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

// tag::type_list[]
* <<esql-to_boolean>>
* <<esql-to_cartesianpoint>>
* <<esql-to_datetime>>
* <<esql-to_degrees>>
* <<esql-to_double>>
* <<esql-to_geopoint>>
* <<esql-to_integer>>
* <<esql-to_ip>>
* <<esql-to_long>>
Expand All @@ -22,9 +24,11 @@
// end::type_list[]

include::to_boolean.asciidoc[]
include::to_cartesianpoint.asciidoc[]
include::to_datetime.asciidoc[]
include::to_degrees.asciidoc[]
include::to_double.asciidoc[]
include::to_geopoint.asciidoc[]
include::to_integer.asciidoc[]
include::to_ip.asciidoc[]
include::to_long.asciidoc[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ long:long |pt:geo_point
;

convertFromString#[skip:-8.11.99, reason:spatial type geo_point only added in 8.12]
// tag::to_geopoint-str[]
row wkt = "POINT(42.97109630194 14.7552534413725)"
| eval pt = to_geopoint(wkt);
| eval pt = to_geopoint(wkt)
// end::to_geopoint-str[]
;

// tag::to_geopoint-str-result[]
wkt:keyword |pt:geo_point
"POINT(42.97109630194 14.7552534413725)" |POINT(42.97109630194 14.7552534413725)
// end::to_geopoint-str-result[]
;

convertFromLongArray#[skip:-8.11.99, reason:spatial type geo_point only added in 8.12]
Expand Down Expand Up @@ -57,14 +62,18 @@ long:long |pt:cartesian_point
;

convertCartesianFromString#[skip:-8.11.99, reason:spatial type cartesian_point only added in 8.12]
// tag::to_cartesianpoint-str[]
row wkt = ["POINT(4297.11 -1475.53)", "POINT(7580.93 2272.77)"]
| mv_expand wkt
| eval pt = to_cartesianpoint(wkt)
| eval l = to_long(pt);
// end::to_cartesianpoint-str[]
;

wkt:keyword |pt:cartesian_point |l:long
"POINT(4297.11 -1475.53)" |POINT(4297.11 -1475.53) |5009771769843126025
"POINT(7580.93 2272.77)" |POINT(7580.93 2272.77) |5038656556796611666
// tag::to_cartesianpoint-str-result[]
wkt:keyword |pt:cartesian_point
"POINT(4297.11 -1475.53)" |POINT(4297.11 -1475.53)
"POINT(7580.93 2272.77)" |POINT(7580.93 2272.77)
// end::to_cartesianpoint-str-result[]
;

convertCartesianFromLongArray#[skip:-8.11.99, reason:spatial type cartesian_point only added in 8.12]
Expand Down

0 comments on commit e1835c9

Please sign in to comment.