dsl查询用法如下:
GET /your_index/_search
{
"_source": {
"includes": [
"timestamp", // Include the timestamp field in the search results
// Other fields you want to include
],
"excludes": []
},
"query": {
// Your query here
},
"script_fields": {
"formatted_timestamp": {
"script": {
"source": "doc['timestamp'].value.format('yyyy-MM-dd HH:mm:ss')"
}
}
}
}
示例:
{
"_source": {
"includes": [
"_host",
"_time"
],
"excludes": []
},
"query": {
"match_all": {}
},
"script_fields": {
"formatted_time": {
"script": {
"source": "doc['_time'].value != null ? doc['_time'].value.toInstant().toString() : null"
}
}
}
}
文章来源地址https://www.toymoban.com/news/detail-632726.html
文章来源:https://www.toymoban.com/news/detail-632726.html
到了这里,关于elasticsearch 将时间类型为时间戳保存格式的时间字段格式化返回的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!