一尘不染

Elasticsearch _timestamp

elasticsearch

我试图_timestamp在索引上定义属性。首先,我创建索引

curl -XPUT 'http://elasticsearch:9200/ppe/'

来自服务器的响应: {"ok":true,"acknowledged":true}

然后我尝试使用 _timestamp

curl -Xput 'http://elasticsearch:9200/ppe/log/_mapping' -d '{
  "log": {
    "properties": {
      "_ttl": {
        "enabled": true
      },
      "_timestamp": {
        "enabled": true,
        "store": "yes"
      },
      "message": {
        "type": "string",
        "store": "yes"
      },
      "appid": {
        "type": "string",
        "store": "yes"
      },
      "level": {
        "type": "integer",
        "store": "yes"
      },
      "logdate": {
        "type": "date",
        "format": "date_time_no_millis",
        "store": "yes"
      }
    }
  }
}'

我收到服务器的答复

{
  "error": "MapperParsingException[No type specified for property [_timestamp]]",
  "status": 400
}

我的映射有什么问题?


阅读 244

收藏
2020-06-22

共1个答案

一尘不染

特殊字段(例如_ttl和)_timestamp必须在与properties对象相同的级别上定义:

curl -Xput 'http://elasticsearch:9200/ppe/log/_mapping' -d '{
    "log": {
        "_ttl": {
            "enabled": true
        },
        "_timestamp": {
            "enabled": true,
            "store": "yes"
        },
        "properties": {
            "message": {
                "type": "string",
                "store": "yes"
            },
            "appid": {
                "type": "string",
                "store": "yes"
            },
            "level": {
                "type": "integer",
                "store": "yes"
            },
            "logdate": {
                "type": "date",
                "format": "date_time_no_millis",
                "store": "yes"
            }
        }
    }
}
'
2020-06-22