创建ttl后将_timestamp添加到索引中以使用它而不是索引时间

时间:2015-10-28 18:52:52

标签: indexing elasticsearch ttl

我尝试在创建索引之后为我的文档类型启用_timestamp字段,并且在已经索引许多文档之后,根据_timestamp字段而不是索引时间将ttl的行为更改为delete。 / p>

我的第一个问题是,此时创建后对映射的这种添加是否会产生预期效果?

其次,当我尝试添加这样的映射时

    curl -XPUT "http://localhost:9200/index/type/_mapping" -d'
    {
      "type": {
      "_timestamp" : {
          "enabled" : true,
          "path" : "timestamp",
          "format" : "yyyy-MM-dd HH:mm:ss.SSS"
      }
    }
   }'

我收到以下错误: Cannot update path in _timestamp value. Value is null path in merged mapping is missing

我不确定问题是什么,因为每个文档都包含时间戳字段

我现有的映射是:

{
  "events_index" : {
    "mappings" : {
      "events" : {
        "dynamic_templates" : [ {
          "notanalyzed" : {
            "mapping" : {
              "index" : "not_analyzed",
              "doc_values" : true,
              "type" : "string"
            },
            "match" : "*",
            "match_mapping_type" : "string"
          }
        } ],
        "_ttl" : {
          "enabled" : true,
          "default" : 2592000000
        },
        "properties" : {
          "@timestamp" : {
            "type" : "date",
            "format" : "dateOptionalTime"
          },
          "@version" : {
            "type" : "string",
            "index" : "not_analyzed",
            "doc_values" : true
          },
          "event" : {
            "properties" : {
               "event_hash" : {
               "type" : "string",
               "index" : "not_analyzed",
               "doc_values" : true
          },
          "geoip" : {
            "properties" : {
              "location" : {
                "type" : "geo_point"
              }
            }
          },
          "timestamp" : {
            "type" : "date",
            "format" : "yyyy-MM-dd HH:mm:ss.SSS"
          },
          "type" : {
            "type" : "string",
            "index" : "not_analyzed",
            "doc_values" : true
          },
          "user" : {
            "properties" : {
              "username" : {
                "type" : "string",
                "index" : "not_analyzed",
                "doc_values" : true
              }
            }
          }
        }
      }
    }
  }
}

0 个答案:

没有答案