Currently I have an API that on initialization checks if my index exists, if not it creates it and applies my mapping, then allows the client to index documents. By and large this works well however sometimes we run into an issue where the index is purged from the system while processes are still indexing. This causes the index to be created but with no mapping so ES guesses at the mapping (uses defaults like text where I want keywords).
I don't want to add logic to check the index mapping is correct before every index request, and that wouldn't work 100% of the time anyway. Is there some way to make the index get created with the correct mapping on index (as well as my other features - shard count, replica count, etc...)? I imagine this is a semi-common problem when folks don't have the ability to stop all publishers when an index needs purged. If possible I'd like to be able to do this from the client as not all indexes have the same mapping.