# Geo\_point mapping from Couchbase to Elasticsearch

**URL:** <https://discuss.elastic.co/t/geo-point-mapping-from-couchbase-to-elasticsearch/41384>\
**Category:** Elasticsearch\
**Created:** [February 10, 2016, 2:16pm UTC](https://discuss.elastic.co/t/geo-point-mapping-from-couchbase-to-elasticsearch/41384 "2016-02-10T14:16:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vatsal\_Patel](https://avatars.discourse-cdn.com/v4/letter/v/ad7895/32.png) [@Vatsal\_Patel](https://discuss.elastic.co/u/Vatsal_Patel)\
**Post date:** [February 10, 2016, 2:16pm UTC](https://discuss.elastic.co/t/geo-point-mapping-from-couchbase-to-elasticsearch/41384/1 "2016-02-10T14:16:44Z")

</div>

I have geo location stored in Cochbase with below format,

> "location": {  
> "lat": 40.722,  
> "lon": -73.989  
> }

Now, How can i mapped this value to Elasticsearch?. I want to perform geo\_distance sorting on that.Thank you.

---

<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:** [February 10, 2016, 2:32pm UTC](https://discuss.elastic.co/t/geo-point-mapping-from-couchbase-to-elasticsearch/41384/2 "2016-02-10T14:32:04Z")

</div>

You need to define a mapping for this location field.  
And set it as geo\_point

---

<div class="post-metadata">

**Author:** ![Vatsal\_Patel](https://avatars.discourse-cdn.com/v4/letter/v/ad7895/32.png) [@Vatsal\_Patel](https://discuss.elastic.co/u/Vatsal_Patel)\
**Post date:** [February 10, 2016, 2:37pm UTC](https://discuss.elastic.co/t/geo-point-mapping-from-couchbase-to-elasticsearch/41384/3 "2016-02-10T14:37:16Z")

</div>

Can i define dynamically.Like below.

"couchbaseDocument": {  
"dynamic\_templates": [  
{  
"documents\_to\_es": {  
"mapping": {  
"type": "geo\_point",  
"lat\_lon"="true"  
},  
"match\_mapping\_type": "double",  
"match": "\*"  
}  
}  
]  
},

Because when i am not applying mapping, Elasticsearch map it as a "double".

---

<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:** [February 10, 2016, 2:55pm UTC](https://discuss.elastic.co/t/geo-point-mapping-from-couchbase-to-elasticsearch/41384/4 "2016-02-10T14:55:48Z")

</div>

Please format your code when posting.

I remember that couchbase defines a template. You need to change it and defines `location` as a `geo_point`.

Look at:

- [https://www.elastic.co/guide/en/elasticsearch/reference/2.2/geo-point.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.2/geo-point.html)
- [https://www.elastic.co/guide/en/elasticsearch/reference/2.2/dynamic-templates.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.2/dynamic-templates.html)

Note that in your case, you know for sure that `location` is a geo point so you don't need to apply a dynamic template but just define the right mapping for the field for your type.

basically, changes this: [https://github.com/couchbaselabs/elasticsearch-transport-couchbase/blob/master/src/main/resources/couchbase\_template.json](https://github.com/couchbaselabs/elasticsearch-transport-couchbase/blob/master/src/main/resources/couchbase_template.json)

---

<div class="post-metadata">

**Author:** ![Vatsal\_Patel](https://avatars.discourse-cdn.com/v4/letter/v/ad7895/32.png) [@Vatsal\_Patel](https://discuss.elastic.co/u/Vatsal_Patel)\
**Post date:** [February 10, 2016, 4:09pm UTC](https://discuss.elastic.co/t/geo-point-mapping-from-couchbase-to-elasticsearch/41384/5 "2016-02-10T16:09:06Z")

</div>

> [@dadoonet](#):
>
> [Dynamic templates | Elasticsearch Guide [2.2] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/2.2/dynamic-templates.html)

Thank you very much for your advice. i will keep in mind for code formating.

---

<div class="post-metadata">

**Author:** ![Vatsal\_Patel](https://avatars.discourse-cdn.com/v4/letter/v/ad7895/32.png) [@Vatsal\_Patel](https://discuss.elastic.co/u/Vatsal_Patel)\
**Post date:** [February 10, 2016, 4:21pm UTC](https://discuss.elastic.co/t/geo-point-mapping-from-couchbase-to-elasticsearch/41384/6 "2016-02-10T16:21:36Z")

</div>

```
 I have made below changes, Is it ok or i miss something?.Thank you in advance.

   PUT _template/couchbae
     {
        "template" : "*",
        "order" : 10,
        "mappings" : {
            "couchbaseCheckpoint" : {
                "_source" : {
                    "includes" : ["doc.*"]
                },
                "dynamic_templates": [
                    {
                        "store_no_index": {
                            "match": "*",
                            "mapping": {
                                "store" : "no",
                                "index" : "no",
                                "include_in_all" : false
                            }
                        }
                    }
                ]
            },
            "couchbaseDocument":{
            "properties": {
                   "location": {
                       "type": "geo_point"
                         }
                   }
            },
            "_default_" : {
                "_source" : {
                    "includes" : ["meta.*"]
                },
                "properties" : {
                    "meta" : {
                        "type" : "object",
                        "include_in_all" : false
                    }
                }
            }
        }
    }
```

---

<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:** [February 10, 2016, 6:19pm UTC](https://discuss.elastic.co/t/geo-point-mapping-from-couchbase-to-elasticsearch/41384/7 "2016-02-10T18:19:49Z")

</div>

It looks good.

---

<div class="post-metadata">

**Author:** ![Vatsal\_Patel](https://avatars.discourse-cdn.com/v4/letter/v/ad7895/32.png) [@Vatsal\_Patel](https://discuss.elastic.co/u/Vatsal_Patel)\
**Post date:** [February 10, 2016, 10:20pm UTC](https://discuss.elastic.co/t/geo-point-mapping-from-couchbase-to-elasticsearch/41384/8 "2016-02-10T22:20:27Z")

</div>

Hi, great it works..thank you

---

<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 5, 2017, 11:17pm UTC](https://discuss.elastic.co/t/geo-point-mapping-from-couchbase-to-elasticsearch/41384/9 "2017-07-05T23:17:25Z")

</div>


