After much research, I can sadly declare that an elegant solution for this doesn't currently exist. While you can declare that a field should not be analyzed, you can't tell it to change its type dynamically nor can you just automatically ignore types.

That practically means that whatever type you send first will be the only type you can index into that field. If you predeclared the field with a type, you then won't be able to index anything other than that type. In either case, all mismatching types will drop. Also, notice that this often floods elasticsearch's logfile and you should either set log rotation or configure elasticsearch to not log those errors in its logging yaml.

Your solution is indeed a potential hack (unless you're certain the un-indexed data is irrelevant). It is much like a try: something except: pass in python.

As a general rule (speaking from experience), I suggest that you don't index different types of data (not different elasticsearch types) into fields with the same name as it then becomes extremely hard to analyze in Kibana when trying to use Number/String based queries (you won't be able to sort or display histograms or piecharts on that specific field.) Obviously, it's not always easy to just change your code (or another application's code) to not index to the same field, in which case, I would identify the originating app and use logstash's grok (unless you're already sending a json) and mutate filters to replace the field's name.