What I have is elasticserach ingesting something like:
{
"policy": {
"name": "account-cloudtrail-enabled",
"resource": "account"
},
"metrics": [{
"MetricName": "ResourceCount",
"Timestamp": "2021-12-06T11:29:48.934903",
"Value": 0,
"Unit": "Count"
}, {
"MetricName": "ResourceTime",
"Timestamp": "2021-12-06T11:29:48.934920",
"Value": 0.8265008926391602,
"Unit": "Seconds"
}]
}
And Elasticseach is upset that the data type in "Value" is different in the two objects. In one, it sees a "long" and a "float" in the other.
"error"=>{"type"=>"illegal_argument_exception", "reason"=>"mapper [cc-data.metrics.Value] cannot be changed from type [float] to [long]"
So, I have been advised to create a "mapping" in Elasticsearch to define the data types as floats at that point. OK... based on what I read here: Nested field type | Elasticsearch Guide [7.16] | Elastic
I think I need something like:
curl -X PUT "localhost:9200/_component_template/myindex?pretty" -H 'Content-Type: application/json' -d'
{
"template": {
"mappings": {
"_source": {
"enabled": false
},
"properties": {
"cc-data.metrics.Value": {
"type": "float"
}
}
}
}
}
What would be the most help might be a little guidance on 2 things:
a. How do I manage these templates? Removing them, adding them, listing them?
b. How to I change the data type for a field inside a data structure like this? I'm just confused as to what all the fields mean.