目录
一、存储格式
JSON 本身没有date类型,Elasticsearch将设置了时区的date转换为UTC时间,将没有设置时区的date直接设置为UTC时间,以long型时间戳存储。
官网文档《Date datatype文档》内容如下
Date datatype
JSON doesn’t have a date datatype, so dates in Elasticsearch can either be:
- strings containing formatted dates, e.g.
"2015-01-01"
or"2015/01/01 12:10:30"
. - a long number representing milliseconds-since-the-epoch.
- an integer representing seconds-since-the-epoch.
Internally, dates are converted to UTC (if the time-zone is specified) and stored as a long number representing milliseconds-since-the-epoch
二、查询统计
- date类型查询,将date转换为long型时间戳查询;
- date类型聚合,返回结果格式化date字符串;
- ElasticSearch查询、存储,将date类型转换为UTC long型时间戳。
- 相同格式存储、查询(同是时间戳或同是格式化字符串),查询时间一致;查询