Indexing nonstandard geo_point field


(Brian Thomas) #1

I am new to Elasticsearch and I am trying to index a json document with a
nonstandard lat/long format.

I know the standard format for a geo_point array is [lon, lat], but the
documents I am indexing has format [lat, lon].

This is what the JSON element looks like:

"geo": {
"type": "Point",
"coordinates": [
38.673459,
-77.336781
]
}

Is there anyway I could have elasticsearch reorder this array or convert
this field to a string without having to modify the source document prior
to indexing? Could this be done using a field mapping or script in
elasticsearch?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/0e688310-5777-4906-889e-cd77693c3908%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Alexander Reelsen) #2

Hey,

you could index this as a geo shape (as this is valid GeoJSON). If you
really need the functionality for a geo_point, you need to change the
structure of the data.

--Alex

On Sat, May 31, 2014 at 3:36 PM, Brian Thomas mynameisbt@gmail.com wrote:

I am new to Elasticsearch and I am trying to index a json document with a
nonstandard lat/long format.

I know the standard format for a geo_point array is [lon, lat], but the
documents I am indexing has format [lat, lon].

This is what the JSON element looks like:

"geo": {
"type": "Point",
"coordinates": [
38.673459,
-77.336781
]
}

Is there anyway I could have elasticsearch reorder this array or convert
this field to a string without having to modify the source document prior
to indexing? Could this be done using a field mapping or script in
elasticsearch?

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/0e688310-5777-4906-889e-cd77693c3908%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/0e688310-5777-4906-889e-cd77693c3908%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGCwEM_MA3vv%2Bpn%2Bdd%2BaUqn8ZWVatP6w7%3Dvdv%2Ba2rEYpeBs3Zg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(Brian Thomas) #3

I looked at the documenation for elasticsearch's geo_shape and it looks
like that use [longitude, latitude]

Found this node on the geo_shape documentation page
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-geo-shape-type.html

Note: In GeoJSON, and therefore Elasticsearch, the correctcoordinate order
is longitude, latitude (X, Y)
within coordinate arrays. This differs from
many Geospatial APIs (e.g., Google Maps) that generally use the colloquial
latitude, longitude (Y, X).

An alternative I found was to use the computed fields plugin

and create a mapping like this:

"@coordinates-str" : {
"type" : "computed",
"script" : "_source.geo.coordinates[0] + ',' +
_source.geo.coordinates[1]",
"result" : {
"type" : "geo_point",
"store" : true
}
}

This seems to create the string in the correct format for the geo point.
The issue I am having with this method right now is that Elasticsearch
will return an error if the source document does not have the
geo.coordinates field.

On Sunday, June 1, 2014 4:28:24 PM UTC-4, Alexander Reelsen wrote:

Hey,

you could index this as a geo shape (as this is valid GeoJSON). If you
really need the functionality for a geo_point, you need to change the
structure of the data.

--Alex

On Sat, May 31, 2014 at 3:36 PM, Brian Thomas <mynam...@gmail.com
<javascript:>> wrote:

I am new to Elasticsearch and I am trying to index a json document with a
nonstandard lat/long format.

I know the standard format for a geo_point array is [lon, lat], but the
documents I am indexing has format [lat, lon].

This is what the JSON element looks like:

"geo": {
"type": "Point",
"coordinates": [
38.673459,
-77.336781
]
}

Is there anyway I could have elasticsearch reorder this array or convert
this field to a string without having to modify the source document prior
to indexing? Could this be done using a field mapping or script in
elasticsearch?

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/0e688310-5777-4906-889e-cd77693c3908%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/0e688310-5777-4906-889e-cd77693c3908%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/48b0ae24-aaa8-4a05-9690-23032974da31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #4