Replying to my own question for other searchers:

My problem had to do with types.  The mapping that ended up working is:

{
    "test" : {
"transform" : {
            "script" : "ctx._source['date_created'] = 
ctx._source['date_created'].toLong() * 1000",
            "lang": "groovy"
        },
        "properties" : {
            "date_created" : {"type" : "date"},
        }
    }
}

Note the "toLong()".

Also, once a script is modified, it appears as though the type has to be 
deleted and the mapping re-applied for the changes to take effect.

  Nick

On Wednesday, December 3, 2014 2:52:10 PM UTC-7, Nick Wood wrote:
>
> Greetings,
>
> My primary data store has a date_created field stored as a unix timestamp. 
>  I've verified that if I multiply that value by 1000 and then index 
> it, Elasticsearch correctly picks the field up as a date.  But updating the 
> data in my primary data store is not very feasible, therefore, I'm looking 
> for some way to have Elasticsearch do the conversion for me.  Lazy, eh?
>
> I've tried adding this to my mapping
>
> --------------------
>         "transform" : {
>             "script" : "ctx._source['date_created'] = 
> ctx._source['date_created'] * 1000;",
>             "lang": "groovy"
>         },
>         "properties" : { ...
> --------------------
>
> I was expecting that to multiply the date_created field by 1000 prior to 
> parsing the field as a date, but it doesn't seem to be working.
>
> Any ideas what I might be doing wrong, or suggestions for an alternate 
> approach?
>
>   Nick
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/991be6f5-31dc-444c-8748-383b8262d074%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to