我最近刚刚将集群从6.1.x升级到7.9.x版本。尝试修复索引模板,以便在午夜过后推送数据时,自动创建新的每日索引。
我是这样做的:
## create template and mapping
PUT http://es1:9200/_template/tmp_staging_devices_1
{
"template": "staging-devices-*",
"settings": {
"number_of_shards": 3
},
"mappings": {
"properties": {
"ts": {"type": "date", "format": "epoch_millis"},
"server_ts": {"type": "date", "format": "epoch_millis"},
"raw": {"type": "binary"}
}
}
}
## template is listed under the list of templates
## trying to put some data into the elasticsearch
PUT http://es1:9200/staging-devices-2020-10-20
{
"imei": "24779610124313",
"json": "{\"imei\":\"357796101614313\",\"ts\":1603180834000,\"values\":{\"coreMsgId\":2810,\"obdIt\":{\"distance\":0,\"distanceCombustion\":0,\"idleTime\":0,\"idleTimeCombustion\":0,\"maxSpeed\":0,\"totalEnergyCons\":0,\"totalFuelCons\":0,\"totalTime\":488,\"totalTimeCombustion\":0}}}",
"raw": "04 00 00 32 0A 18 08 FA 15 32 13 08 00 10 00 18 00 20 00 28 E8 03 30 00 38 00 40 00 48 00 12 0F 33 35 37 37 39 36 31 30 31 36 31 34 33 31 33 18 C2 EE CE D1 CB 2E",
"server_ts": 1603180834000,
"ts": 1603180834000
}
## error that I get back (400 bad request)
{
"error": {
"root_cause": [
{
"type": "parse_exception",
"reason": "unknown key [server_ts] for create index"
}
],
"type": "parse_exception",
"reason": "unknown key [server_ts] for create index"
},
"status": 400
}
我做错什么了?
与“旧系统”唯一不同的是我删除了“值”
{
"template": "staging-devices*",
"settings": {
"number_of_shards": 1
},
"mappings": {
"values": {
"properties": {
"ts": {"type": "date", "format": "epoch_millis"},
"server_ts": {"type": "date", "format": "epoch_millis"},
"raw": {"type": "binary"}
}
}
}
}
1条答案
按热度按时间9fkzdhlc1#
你应该提到
type
和文档id。文件类型
_doc
是elasticsearch 7.x中的默认值。删除Map类型
索引一些文档
试试这个(通过kibana)-测试:
curl :