gpt4 book ai didi

elasticsearch - 在Elasticsearch中将Unix时间戳转换为日期时间

转载 作者:行者123 更新时间:2023-12-02 22:47:05 25 4
gpt4 key购买 nike

我在elasticsearch(使用xdcr)中索引了我的榻榻米文档。在couchbase中,我们有存储unix时间戳的字段,但是我想在ElasticSearch中将它们索引为日期时间。
有没有办法告诉Elasticsearch将Unix时间戳(以秒为单位)转换为日期时间?

谢谢。

最佳答案

没有人回答,因此我继续使用Google搜索,并在这里找到了答案:

http://elasticsearch-users.115913.n3.nabble.com/Convert-unix-timestamp-seconds-to-java-milliseconds-td4067144.html

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

关于elasticsearch - 在Elasticsearch中将Unix时间戳转换为日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28538591/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com