如何获取带有时间戳的ES文档

时间:2017-11-17 01:34:42

标签: elasticsearch

我想访问该文档的时间戳。 我该怎么办?

我用

localhost:9200/cbborder/order/_search

但没有时间戳的结果。

enter image description here

喜欢这个 enter image description here

1 个答案:

答案 0 :(得分:0)

您使用的是哪个版本的ES?如果它小于5.0,那么您可以使用以下映射为每个文档生成时间戳:

curl -XPOST localhost:9200/test -d '{
"settings" : {
    "number_of_shards" : 1
},
"mappings" : {
    "_default_":{
        "_timestamp" : {
            "enabled" : true,
            "store" : true
        }
    }
  }
}'

但是在较新版本的ES中删除了这一点,即在v5.0之后。 但他们提供了其他选项,如管道摄取。