I'm dealing with a problem that I could't solve yet. I've looked up all over the internet and found a bunch of very interesting topics that brought me closer to the answer but weren't enough.
The situation is the following: I have several indices that hold documents for different months. These inidices are pre-created and the auto-create option is disabled, therefore the indices cannot be created dynamically. On the other hand the indices mappings are created dynamically. I cannot know on beforehand what will be the documents's structure.
Nothing assures me that, at the moment I perform a query, I will have a document on every single index created (because I may not have indexed yet a document for a particular month). In that case, all the indices holding some document would've the mappings properly set and the empty indices would not.
Under that scenario, if I perform a query over all the month indices (using an alias or a * wildcard) including a sort clause then it will obviously fail because not all the indices would share the same mappings for the same field (because of the empty indices that has no mapping for that particular field).
How can I handle that situation? I would like to be able to sort over all the indices month even if there is some empty index.
I have read about the (deprecated) ignore_unmapped and the (current) unmapped_type properties. The last one is not useful for me because I cannot know beforehand the documents' structure.