If by creating an index template, it will be applied to indexes that are created in the future (after tomorrow), then that is fine.
I would also like to change the type for indexes that have already been obtained.
For example, I executed the following command
curl -X PUT "localhost:9200/kin-www-access-2022.07.29/_mapping?pretty" -H 'Content-Type: application/json' -d'
{
"properties" : {
"@timestamp" : {
"type" : "date"
},
"@version" : {
"type" : "text"
},
"action" : {
"type" : "text"
},
"agent" : {
"properties" : {
"ephemeral_id" : {
"type" : "text"
},
"hostname" : {
"type" : "text"
},
"id" : {
"type" : "text"
},
"name" : {
"type" : "text"
},
"type" : {
"type" : "text"
},
"version" : {
"type" : "text"
}
}
},
"bytes" : {
"type" : "integer"
},
"ecs" : {
"properties" : {
"version" : {
"type" : "text"
}
}
},
"fields" : {
"properties" : {
"index_name" : {
"type" : "text"
}
}
},
"host" : {
"properties" : {
"architecture" : {
"type" : "text"
},
"containerized" : {
"type" : "boolean"
},
"hostname" : {
"type" : "text"
},
"ip" : {
"type" : "text"
},
"mac" : {
"type" : "text"
},
"name" : {
"type" : "text"
},
"os" : {
"properties" : {
"codename" : {
"type" : "text"
},
"family" : {
"type" : "text"
},
"kernel" : {
"type" : "text"
},
"name" : {
"type" : "text"
},
"platform" : {
"type" : "text"
},
"type" : {
"type" : "text"
},
"version" : {
"type" : "text"
}
}
}
}
},
"input" : {
"properties" : {
"type" : {
"type" : "text"
}
}
},
"ip-address" : {
"type" : "text"
},
"log" : {
"properties" : {
"file" : {
"properties" : {
"path" : {
"type" : "text"
}
}
},
"offset" : {
"type" : "long"
}
}
},
"message" : {
"type" : "text"
},
"path" : {
"type" : "text"
},
"protocol" : {
"type" : "text"
},
"status" : {
"type" : "text"
},
"tags" : {
"type" : "text"
},
"timestamp" : {
"type" : "text"
},
"url" : {
"type" : "text"
},
"user" : {
"type" : "text"
},
"user_agent" : {
"type" : "text"
},
"username" : {
"type" : "text"
}
}
}'
However, it does not work.
I get the following error
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "mapper [bytes] cannot be changed from type [text] to [integer]"
}
],
"type" : "illegal_argument_exception",
"reason" : "mapper [bytes] cannot be changed from type [text] to [integer]"
},
"status" : 400
}
Can I achieve what I want to do?