Fetching all params keys and values

I am using painless script query in elasticsearch and I want to fetch all the keys inside params. So I want to access it like params[0].key. Something like that. But do not find the proper syntax. Can anyone help me out?

params is essentially a java map, so you can get a set of all keys by calling params.keySet()