I am importing a document twice into the same index but different types. However, I got a [mapper_parsing_exception] when I import the document the second time.
Below are my steps.
-
Create the template for the index.
{ "order": 0, "template": "stats-*", "settings": { "index": { "number_of_shards": "1", "number_of_replicas": "1", "refresh_interval": "5s" } }, "mappings": { "_default_": { "include_in_all": false, "dynamic_templates": [ { "metrics_fields": { "path_match": "metrics.*", "mapping": { "scaling_factor": 100, "type": "scaled_float" } } } ], "_all": { "norms": false, "enabled": true }, "properties": { "@timestamp": { "type": "date" }, "@version": { "type": "keyword" } } } }, "aliases": {} }
-
Import the document into type
a
. The import was successful.POST stats-demo/a { "@timestamp": "2017-04-19T03:40:04.000Z", "@version": "1", "metrics": { "blockout": 0, "memory": 569.2, "cpu": 1420.4, "blockin": 123.5, "netout": 0, "memlimit": 1024, "netin": 0 } }
-
Import the same document into type
b
of the same index. The following exception was thrown:{ "error": { "root_cause": [ { "type": "mapper_parsing_exception", "reason": "failed to parse" } ], "type": "mapper_parsing_exception", "reason": "failed to parse", "caused_by": { "type": "illegal_argument_exception", "reason": "Field [blockout] misses required parameter [scaling_factor]" } }, "status": 400 }
Below is the mapping of the stats-demo
after the first successful import:
{
"stats-demo": {
"aliases": {},
"mappings": {
"_default_": {
"include_in_all": false,
"_all": {
"enabled": true,
"norms": false
},
"dynamic_templates": [
{
"metrics_fields": {
"path_match": "metrics.*",
"mapping": {
"scaling_factor": 100,
"type": "scaled_float"
}
}
}
],
"properties": {
"@timestamp": {
"type": "date"
},
"@version": {
"type": "keyword"
}
}
},
"a": {
"include_in_all": false,
"_all": {
"enabled": true,
"norms": false
},
"dynamic_templates": [
{
"metrics_fields": {
"path_match": "metrics.*",
"mapping": {
"scaling_factor": 100,
"type": "scaled_float"
}
}
}
],
"properties": {
"@timestamp": {
"type": "date"
},
"@version": {
"type": "keyword"
},
"metrics": {
"properties": {
"blockin": {
"type": "scaled_float",
"scaling_factor": 100
},
"blockout": {
"type": "scaled_float",
"scaling_factor": 100
},
"cpu": {
"type": "scaled_float",
"scaling_factor": 100
},
"memlimit": {
"type": "scaled_float",
"scaling_factor": 100
},
"memory": {
"type": "scaled_float",
"scaling_factor": 100
},
"netin": {
"type": "scaled_float",
"scaling_factor": 100
},
"netout": {
"type": "scaled_float",
"scaling_factor": 100
}
}
}
}
}
},
"settings": {
"index": {
"refresh_interval": "5s",
"number_of_shards": "1",
"provided_name": "stats-demo",
"creation_date": "1492669920734",
"number_of_replicas": "1",
"uuid": "_kbN2j5sTBieLc08Zcg6vA",
"version": {
"created": "5020299"
}
}
}
}
}
I am confusing why the same document couldn't be imported into another type
of the same index.
Thank you for any help. Any possible solution is appreciated!