Repeating for emphasis:
If your application needs to support older versions of Elasticsearch then this approach will need some kind of mechanism that detects the cluster version and adjusts your application behaviour accordingly.
It's not just the deprecation warning, it's also the fact that you're using a feature which is deprecated. IMO the latter bit is worth addressing, and once addressed it'll get rid of the warning too.