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

Added documentation on GeoJSON format for points and geo-points #86066

Merged
merged 2 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ about how to use runtime fields.
Accepts the values from the script valuation. Scripts can call the
`emit` method multiple times to emit multiple values.
+
The `emit` method applies only to scripts used in a
The `emit` method applies only to scripts used in a
<<painless-execute-runtime-context,runtime fields context>>.
+
IMPORTANT: The `emit` method cannot accept `null` values. Do not call this
Expand All @@ -30,7 +30,7 @@ The signature for `emit` depends on the `type` of the field.
`boolean`:: `emit(boolean)`
`date`:: `emit(long)`
`double`:: `emit(double)`
`geo_point`:: `emit(double lat, double long)`
`geo_point`:: `emit(double lat, double lon)`
`ip`:: `emit(String)`
`long`:: `emit(long)`
`keyword`:: `emit(String)`
Expand Down
9 changes: 5 additions & 4 deletions docs/painless/painless-guide/painless-execute-script.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ sorted list of `double` values. See
<<painless-runtime-double,double_field context>>.

`geo_point_field`::
The context for {ref}/geo-point.html[`geo-point` fields]. `emit` takes a
`geo-point` value and the script returns coordinates for the geo point. See
The context for {ref}/geo-point.html[`geo-point` fields]. `emit` takes two double
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iverase Could you verify this change. I think the old description seemed quite incorrect.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a look and yes the explanation of the emit is correct, thanks! What it is not clear to me what we refer here to what the script returns. This is currently a bug as it should behave as an indexed geo_point which is not the case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this geo_point context is different to the out put of the fields API. lThe change looks good to me then.

parameters, the latitude and longitude values, and the script returns an object in
GeoJSON format containing the coordinates for the geo point. See
<<painless-runtime-geo,geo_point_field context>>.

`ip_field`::
Expand Down Expand Up @@ -598,7 +599,7 @@ PUT /my-index-000001/
----

You can then use the `geo_point_field` runtime field context to write a script
that retrieves the `lat` and `long` values.
that retrieves the `lat` and `lon` values.

[source,console]
----
Expand All @@ -621,7 +622,7 @@ POST /_scripts/painless/_execute
----
// TEST[continued]

Because this you're working with a geo-point field type, the response includes
Because you're working with a geo-point field type, the response includes
results that are formatted as `coordinates`.

[source,console-result]
Expand Down