Get consolidated schema of multiple indices in ES


I've multiple indices in Elasticsearch that has similar data. But, each index has new properties added/removed over the period of time. Is there any way to fetch union of all indices schema using KQL?

For example,

   "id": "123",
   "name" :"es"
   "age" : 25

   "id": "123",
   "name" :"es"
   "dept" : "hr"
   "sal" : "5000"
   "currencycode" : "USD"

With above two indices, "Age" is removed in Index_2020 and additional attributes are added in 2021 index. I've these indices mapped almost every month in my system for last few years. It would be tedious process to understand the schema manually. Wondering if there is any way we could get consolidated or Union schema of all these indices?

Here is the schema output I'm looking for


I think I would create an index pattern or data view for the indices you are looking at depending on which version you're on and then that