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"}}}
}