我试图_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
}
我的映射有什么问题?
特殊字段(例如_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"
}
}
}
}
'