# Indexing nonstandard geo\_point field

**URL:** <https://discuss.elastic.co/t/indexing-nonstandard-geo-point-field/17842>\
**Category:** Elasticsearch\
**Created:** [May 31, 2014, 1:36pm UTC](https://discuss.elastic.co/t/indexing-nonstandard-geo-point-field/17842 "2014-05-31T13:36:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Thomas](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@Brian\_Thomas](https://discuss.elastic.co/u/Brian_Thomas)\
**Post date:** [May 31, 2014, 1:36pm UTC](https://discuss.elastic.co/t/indexing-nonstandard-geo-point-field/17842/1 "2014-05-31T13:36:13Z")

</div>

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](mailto: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).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [June 1, 2014, 8:28pm UTC](https://discuss.elastic.co/t/indexing-nonstandard-geo-point-field/17842/2 "2014-06-01T20:28:15Z")

</div>

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](mailto: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](mailto: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)  
> [https://groups.google.com/d/msgid/elasticsearch/0e688310-5777-4906-889e-cd77693c3908%40googlegroups.com?utm\_medium=email&utm\_source=footer](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](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](mailto: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](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](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Brian\_Thomas](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@Brian\_Thomas](https://discuss.elastic.co/u/Brian_Thomas)\
**Post date:** [June 2, 2014, 4:19am UTC](https://discuss.elastic.co/t/indexing-nonstandard-geo-point-field/17842/3 "2014-06-02T04:19:20Z")

</div>

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

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Note: In GeoJSON, and therefore Elasticsearch, the correct_coordinate 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

> **[GitHub - SkillPages/elasticsearch-computed-fields: Computed fields plugin for...](https://github.com/SkillPages/elasticsearch-computed-fields)**
>
> Computed fields plugin for ElasticSearch http://www.elasticsearch.org - GitHub - SkillPages/elasticsearch-computed-fields: Computed fields plugin for ElasticSearch http://www.elasticsearch.org

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](mailto: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](mailto: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)  
> > [https://groups.google.com/d/msgid/elasticsearch/0e688310-5777-4906-889e-cd77693c3908%40googlegroups.com?utm\_medium=email&utm\_source=footer](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](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](mailto: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](https://groups.google.com/d/msgid/elasticsearch/48b0ae24-aaa8-4a05-9690-23032974da31%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:25am UTC](https://discuss.elastic.co/t/indexing-nonstandard-geo-point-field/17842/4 "2017-07-06T01:25:21Z")

</div>


