# How to map a non-standard geo\_type

**URL:** <https://discuss.elastic.co/t/how-to-map-a-non-standard-geo-type/13509>\
**Category:** Elasticsearch\
**Created:** [September 8, 2013, 11:55pm UTC](https://discuss.elastic.co/t/how-to-map-a-non-standard-geo-type/13509 "2013-09-08T23:55:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oleg](https://avatars.discourse-cdn.com/v4/letter/o/ebca7d/32.png) [@Oleg](https://discuss.elastic.co/u/Oleg)\
**Post date:** [September 8, 2013, 11:55pm UTC](https://discuss.elastic.co/t/how-to-map-a-non-standard-geo-type/13509/1 "2013-09-08T23:55:42Z")

</div>

Hi,

I ingest data from CouchDB into ElasticSearch and would like my lat, lon to  
be mapped as geo\_type, but I don't know how to do it, since my lat, lon is  
not fitting any of the geo\_type examples from the guide.

My data looks like this:

"location": {  
"latitude": 37.632571793,  
"name": "Pacifica Pier",  
"longitude": -122.494277492,  
"id": 5076543  
}

(of course there are a bunch of other fields)

Since the "location" doesn't have an array [lat, lon] I'm not sure how to specify the type to be "geo\_type".

Would something like this work?

```
"location":{
         "properties":{
                   "id":{"type":"long"},
                   "latitude":{"type":"geo_type"},
                   "longitude":{"type":"geo_type"},
                   "name":{"type":"string"}

          }

}

```

How can I combine the two values into one array?

I'd highly appreciate any suggestions or help.

Thanks!

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 9, 2013, 4:51am UTC](https://discuss.elastic.co/t/how-to-map-a-non-standard-geo-type/13509/2 "2013-09-09T04:51:54Z")

</div>

It can not work out of the box.  
You could think of using a script to create a new locationgeo field, and copy lat,lon values in it:  
"location" : "lat,lon"  
Have a look at: [https://github.com/elasticsearch/elasticsearch-river-couchdb#script-filters](https://github.com/elasticsearch/elasticsearch-river-couchdb#script-filters)

## HTH

David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 9 sept. 2013 à 01:55, Oleg Aulov [aulov.oleg@gmail.com](mailto:aulov.oleg@gmail.com) a écrit :

Hi,

I ingest data from CouchDB into ElasticSearch and would like my lat, lon to be mapped as geo\_type, but I don't know how to do it, since my lat, lon is not fitting any of the geo\_type examples from the guide.

My data looks like this:

"location": {  
"latitude": 37.632571793,  
"name": "Pacifica Pier",  
"longitude": -122.494277492,  
"id": 5076543  
}

(of course there are a bunch of other fields)

Since the "location" doesn't have an array [lat, lon] I'm not sure how to specify the type to be "geo\_type".

Would something like this work?

```
"location":{
         "properties":{
                   "id":{"type":"long"},
                   "latitude":{"type":"geo_type"},
                   "longitude":{"type":"geo_type"},
                   "name":{"type":"string"}
          }
}

```

How can I combine the two values into one array?

I'd highly appreciate any suggestions or help.

Thanks!

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 9, 2013, 4:54am UTC](https://discuss.elastic.co/t/how-to-map-a-non-standard-geo-type/13509/3 "2013-09-09T04:54:46Z")

</div>

My answer supposed that you are using couchdb river. Is it true?

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 9 sept. 2013 à 06:51, David Pilato [david@pilato.fr](mailto:david@pilato.fr) a écrit :

It can not work out of the box.  
You could think of using a script to create a new locationgeo field, and copy lat,lon values in it:  
"location" : "lat,lon"  
Have a look at: [https://github.com/elasticsearch/elasticsearch-river-couchdb#script-filters](https://github.com/elasticsearch/elasticsearch-river-couchdb#script-filters)

## HTH

David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 9 sept. 2013 à 01:55, Oleg Aulov [aulov.oleg@gmail.com](mailto:aulov.oleg@gmail.com) a écrit :

Hi,

I ingest data from CouchDB into ElasticSearch and would like my lat, lon to be mapped as geo\_type, but I don't know how to do it, since my lat, lon is not fitting any of the geo\_type examples from the guide.

My data looks like this:

"location": {  
"latitude": 37.632571793,  
"name": "Pacifica Pier",  
"longitude": -122.494277492,  
"id": 5076543  
}

(of course there are a bunch of other fields)

Since the "location" doesn't have an array [lat, lon] I'm not sure how to specify the type to be "geo\_type".

Would something like this work?

```
"location":{
         "properties":{
                   "id":{"type":"long"},
                   "latitude":{"type":"geo_type"},
                   "longitude":{"type":"geo_type"},
                   "name":{"type":"string"}
          }
}

```

How can I combine the two values into one array?

I'd highly appreciate any suggestions or help.

Thanks!

## -- 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). For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Oleg](https://avatars.discourse-cdn.com/v4/letter/o/ebca7d/32.png) [@Oleg](https://discuss.elastic.co/u/Oleg)\
**Post date:** [September 9, 2013, 5:07am UTC](https://discuss.elastic.co/t/how-to-map-a-non-standard-geo-type/13509/4 "2013-09-09T05:07:10Z")

</div>

Hi David, thanks for a prompt reply! Yes, using CouchDB river.

Makes sense. So if there is a script in the river that moves lat, lon into  
an array then Elasticsearch is going to see the structure in the right form.

On Monday, September 9, 2013 12:54:46 AM UTC-4, David Pilato wrote:

> My answer supposed that you are using couchdb river. Is it true?
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 9 sept. 2013 à 06:51, David Pilato \<[da...@pilato.fr](mailto:da...@pilato.fr) \<javascript:\>\> a  
> écrit :
> 
> It can not work out of the box.  
> You could think of using a script to create a new locationgeo field, and  
> copy lat,lon values in it:
> 
> "location" : "lat,lon"
> 
> Have a look at:  
> [GitHub - elastic/elasticsearch-river-couchdb: CouchDB River Plugin for elasticsearch (STOPPED)](https://github.com/elasticsearch/elasticsearch-river-couchdb#script-filters)
> 
> ## HTH
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 9 sept. 2013 à 01:55, Oleg Aulov \<[aulov...@gmail.com](mailto:aulov...@gmail.com) \<javascript:\>\> a  
> écrit :
> 
> Hi,
> 
> I ingest data from CouchDB into Elasticsearch and would like my lat, lon  
> to be mapped as geo\_type, but I don't know how to do it, since my lat, lon  
> is not fitting any of the geo\_type examples from the guide.
> 
> My data looks like this:
> 
> "location": {  
> "latitude": 37.632571793,  
> "name": "Pacifica Pier",  
> "longitude": -122.494277492,  
> "id": 5076543  
> }
> 
> (of course there are a bunch of other fields)
> 
> Since the "location" doesn't have an array [lat, lon] I'm not sure how to specify the type to be "geo\_type".
> 
> Would something like this work?
> 
> ```
> "location":{
> "properties":{
> "id":{"type":"long"},
> "latitude":{"type":"geo_type"},
> "longitude":{"type":"geo_type"},
> "name":{"type":"string"}
> 
> }
> 
> }
> 
> ```
> 
> How can I combine the two values into one array?
> 
> I'd highly appreciate any suggestions or help.
> 
> Thanks!
> 
> --  
> 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:\>.  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> 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:\>.  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 9, 2013, 5:46am UTC](https://discuss.elastic.co/t/how-to-map-a-non-standard-geo-type/13509/5 "2013-09-09T05:46:09Z")

</div>

Yeah. I guess it should work.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 9 sept. 2013 à 07:07, Oleg Aulov [aulov.oleg@gmail.com](mailto:aulov.oleg@gmail.com) a écrit :

Hi David, thanks for a prompt reply! Yes, using CouchDB river.

Makes sense. So if there is a script in the river that moves lat, lon into an array then Elasticsearch is going to see the structure in the right form.

On Monday, September 9, 2013 12:54:46 AM UTC-4, David Pilato wrote:

> My answer supposed that you are using couchdb river. Is it true?
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 9 sept. 2013 à 06:51, David Pilato [da...@pilato.fr](mailto:da...@pilato.fr) a écrit :
> 
> It can not work out of the box.  
> You could think of using a script to create a new locationgeo field, and copy lat,lon values in it:  
> "location" : "lat,lon"  
> Have a look at: [GitHub - elastic/elasticsearch-river-couchdb: CouchDB River Plugin for elasticsearch (STOPPED)](https://github.com/elasticsearch/elasticsearch-river-couchdb#script-filters)
> 
> ## HTH
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 9 sept. 2013 à 01:55, Oleg Aulov [aulov...@gmail.com](mailto:aulov...@gmail.com) a écrit :
> 
> Hi,
> 
> I ingest data from CouchDB into Elasticsearch and would like my lat, lon to be mapped as geo\_type, but I don't know how to do it, since my lat, lon is not fitting any of the geo\_type examples from the guide.
> 
> My data looks like this:
> 
> "location": {  
> "latitude": 37.632571793,  
> "name": "Pacifica Pier",  
> "longitude": -122.494277492,  
> "id": 5076543  
> }
> 
> (of course there are a bunch of other fields)
> 
> Since the "location" doesn't have an array [lat, lon] I'm not sure how to specify the type to be "geo\_type".
> 
> Would something like this work?
> 
> ```
> "location":{
> "properties":{
> "id":{"type":"long"},
> "latitude":{"type":"geo_type"},
> "longitude":{"type":"geo_type"},
> "name":{"type":"string"}
> }
> }
> 
> ```
> 
> How can I combine the two values into one array?
> 
> I'd highly appreciate any suggestions or help.
> 
> Thanks!
> 
> ## -- 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). For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)\
**Post date:** [September 9, 2013, 6:55pm UTC](https://discuss.elastic.co/t/how-to-map-a-non-standard-geo-type/13509/6 "2013-09-09T18:55:08Z")

</div>

Be careful. See

> **[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.

If added as a string, then it's "location" : "lat, lon"

But if added as an array, then it's "location" : [lon, lat] to conform  
with GeoJSON.

Because GeoJSON follows the x-y-z coordinate system conventions, longitude  
must come first if specified in an array of floating-point values. But  
latitude comes first if the "array" is really a single string with two  
comma-separated floating-point string values embedded in it.

Brian

On Monday, September 9, 2013 1:07:10 AM UTC-4, Oleg Aulov wrote:

> Hi David, thanks for a prompt reply! Yes, using CouchDB river.
> 
> Makes sense. So if there is a script in the river that moves lat, lon into  
> an array then Elasticsearch is going to see the structure in the right form.
> 
> >

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Oleg](https://avatars.discourse-cdn.com/v4/letter/o/ebca7d/32.png) [@Oleg](https://discuss.elastic.co/u/Oleg)\
**Post date:** [September 16, 2013, 8:22pm UTC](https://discuss.elastic.co/t/how-to-map-a-non-standard-geo-type/13509/7 "2013-09-16T20:22:07Z")

</div>

Thank you David and Brian.  
Following your suggestions I was able to fix my index.  
Here's what I did, in case someone else has a similar problem:

I installed the JavaScript plugin on my Elasticsearch cluster, restarted  
the cluster and executed the following river query:

curl -XPUT 'localhost:9200/\_river/test2/\_meta' -d '{

"type" : "couchdb",

"couchdb" : {

```
   "host" : "localhost",

   "port" : 5984,

   "db" : "instagram_hurricanesandy",

   "script": "if (ctx.doc.location != undefined) 

```

{ctx.doc.location.geopoint = [ctx.doc.location.longitude,  
ctx.doc.location.latitude];}",

```
   "filter" : null

```

},

"index" : {

```
   "index" : "instagramsandy",

   "type" : "instagram",

   "bulk_size" : "100",

   "bulk_timeout" : "10ms"

```

}  
}'

So, the script entry has a JavaScript code that takes Latitude, Nongtitude  
String fields and creates an array of [lon, lat].  
As a result, having the following index mapping worked flawlessly in  
indexing geo\_points:

"location":{

"properties":{

"id":{"type":"long"},

"latitude":{"type":"double"},

"longitude":{"type":"double"},

"geopoint":{"type": "geo\_point"},

"name":{"type":"string"}}},

On Monday, September 9, 2013 2:55:08 PM UTC-4, InquiringMind wrote:

> Be careful. See  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/geo-point-type/)
> 
> If added as a string, then it's "location" : "lat, lon"
> 
> But if added as an array, then it's "location" : [lon, lat] to conform  
> with GeoJSON.
> 
> Because GeoJSON follows the x-y-z coordinate system conventions, longitude  
> must come first if specified in an array of floating-point values. But  
> latitude comes first if the "array" is really a single string with two  
> comma-separated floating-point string values embedded in it.
> 
> Brian
> 
> On Monday, September 9, 2013 1:07:10 AM UTC-4, Oleg Aulov wrote:
> 
> > Hi David, thanks for a prompt reply! Yes, using CouchDB river.
> > 
> > Makes sense. So if there is a script in the river that moves lat, lon  
> > into an array then Elasticsearch is going to see the structure in the right  
> > form.
> > 
> > >

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:16am UTC](https://discuss.elastic.co/t/how-to-map-a-non-standard-geo-type/13509/8 "2017-07-06T02:16:13Z")

</div>


