使用默认时间戳创建映射不起作用

时间:2018-08-26 12:22:31

标签: elasticsearch timestamp

我正在尝试使用映射创建索引。 我需要它在他的每个文档中包含默认时间戳。 我在互联网上到处搜索,并完全按照他们的要求进行了搜索。但是代码不起作用。

curl -X PUT "localhost:9200/demo-index-new12345" -H 'Content-Type: 
application/json' -d'
{

"mappings": {

        "doco" : {
          "properties" : {
              "test_date": {
                "type":   "date",
                "format": "yyyy-MM-dd"
              },
              "test_status": {
                "type":   "string"
              }
            },
           "default":{
              "_timestamp" : {
                "enabled" : true,
                "store" : true
              }
           }

        }
    }
}
'

1 个答案:

答案 0 :(得分:0)

您正在运行什么版本的Elasticsearch?默认时间戳在2.x中已弃用,并已删除。如果每个文档上都需要一个时间戳字段,则需要在映射上添加一个字段,将其称为“时间戳”或“创建”。然后,您可以执行以下两项操作之一:

  1. 向“时间戳”字段发送应用程序中每个填充文档的当前日期。
  2. 添加您的应用使用的提取管道。使用摄取管道将日期字段设置为当前时间的示例:https://www.elastic.co/guide/en/elasticsearch/reference/current/accessing-data-in-pipelines.html#accessing-ingest-metadata。有关提取管道的更多信息,请参见hereherehere