I used python ship data from mongodb to elasticsearch.
There is a timestamp field mapping:
"update_time" : {
"type": "date",
"format": "yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
epoch_millis
is used for timestamp.
After everything done, I used range
to query doc in date range. But nothing return. After some researching, I thought the problem was: python timestamp int(time.time())
is 10 digit, but it is 13 digit in elasticsearch , official example :
PUT my_index/my_type/2?timestamp=1420070400000.
so I tried to update the update_time field by multiple 1000:
{
"script": {
"inline": "ctx._source.update_time=ctx._source.update_time*1000"
}
}
Unfortunately, I found all update_time
become minus. Then I come up with that Java int type is pow(2,32) -1
, much lower than 1420070400000
. I guess timestamp field should not be int ? If it is, the document should add this tip.
So I want to update the field value from int to string(I don't want ot change field mapping type, I know change mapping type need reindex, but here only need change value )
But I can't figure out what script I can use, official script document not mention about this