Geo_point mapping from Couchbase to Elasticsearch

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.

You need to define a mapping for this location field.
And set it as geo_point

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".

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:

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

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

 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
                    }
                }
            }
        }
    }

It looks good.

Hi, great it works..thank you