0

I am currently trying to update an index template on Elastic Search 6.7/6.8. Templates are stored in the code and are applied each time my API starts. There are no errors, the request returns 200.

For example, here is a template i am currently using:

{
    "index_patterns": [ "*-ec2-reports" ],
    "version": 11,
    "mappings": {
        "ec2-report": {
            "properties": {
                "account": {
                    "type": "keyword"
                },
                "reportDate": {
                    "type": "date"
                },
                "reportType": {
                    "type": "keyword"
                },
                "instance": {
                    "properties": {
                        "id": {
                            "type": "keyword"
                        },
                        "region": {
                            "type": "keyword"
                        },
                        "state": {
                            "type": "keyword"
                        },
                        "purchasing": {
                            "type": "keyword"
                        },
                        "keyPair": {
                            "type": "keyword"
                        },
                        "type": {
                            "type": "keyword"
                        },
                        "platform": {
                            "type": "keyword"
                        },
                        "tags": {
                            "type": "nested",
                            "properties": {
                                "key": {
                                    "type": "keyword"
                                },
                                "value": {
                                    "type": "keyword"
                                }
                            }
                        },
                        "costs": {
                            "type": "object"
                        },
                        "stats": {
                            "type": "object",
                            "properties": {
                                "cpu": {
                                    "type": "object",
                                    "properties": {
                                            "average": {
                                                "type": "double"
                                            },
                                            "peak": {
                                                "type": "double"
                                            }
                                    }
                                },
                                "network": {
                                    "type": "object",
                                    "properties": {
                                            "in": {
                                                "type": "double"
                                            },
                                            "out": {
                                                "type": "double"
                                            }
                                    }
                                },
                                "volumes": {
                                    "type": "nested",
                                    "properties": {
                                        "id": {
                                            "type": "keyword"
                                        },
                                        "read": {
                                            "type": "double"
                                        },
                                        "write": {
                                            "type": "double"
                                        }
                                    }
                                }
                            }
                        },
                        "recommendation": {
                            "type": "object",
                            "properties": {
                                "instancetype": {
                                    "type": "keyword"
                                },
                                "reason": {
                                    "type": "keyword"
                                },
                                "newgeneration": {
                                    "type": "keyword"
                                }
                            }
                        }
                    }
                }
            },
            "_all": {
                "enabled": false
            },
            "numeric_detection": false,
            "date_detection": false
        }
    }
}

I'd like to add a new keyword field under the properties object like this :

"exampleField": {
    "type": "keyword"
}

but it seems the template is not applied to existing indexes.

When data is inserted into a specific index which use the template, it is stored like this:

"exampleField": {
    "type": "text",
    "fields": {
        "keyword": {
            "type": "keyword",
            "ignore_above": 256
        }
    }
}
    

because the template has not been updated beforehand.

I would expect it to be like:

"exampleField": {
    "type": "keyword"
}

in the index and in the template.

Does someone have any idea on how to have this result? Thank you, Alexandre.

0 Answers0