Elasticsearch epoch mapping using cb template


#1

Hi,

I’m usually able to make es identify an epoch timestamp (seconds) by using transform. However, when I do the same on an extension of the cb template es doesn’t recognize my field.

I’m hoping someone can help me with this!

Here’s my template:

{
   "template" : "cb-",
   "order" : 10,
   "mappings" : {
            "couchbaseCheckpoint" : {
                "_source" : {
                    "includes" : ["doc.*"]
                },
             "dynamic_templates": [
                {
                    "store_no_index": {
                        "match": "*",
                        "mapping": {
                            "store" : "no",
                            "index" : "no",
                            "include_in_all" : false
                        }
                    }
                }
            ]
        },
        "couchbaseDoc" : {
            "_source" : {
                "includes" : ["meta.*", "doc.*"]
            },
            "properties" : {
               "meta" : {
                    "type" : "object",
                    "include_in_all" : false
                },
               "doc": {
                    "dynamic": true,
                    "transform": {
                        "script": "ctx._source['insertEpoch'] = ctx._source['insertEpoch'].toLong() * 1000",
                        "params": {},
                        "lang": "groovy"
                    },
                    "properties": {
                        "insertEpoch": {
                            "type": "date",
                            "include_in_all" : false
                        }
                    }
               }
            }
        }
    }
}

Tnx


#2

Hey @davido, is this something you can help with?