How to convert visualizations exported object to a valid query?

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):

Describe the issue:
I have a use case where i need to export all saved objects (visualizations etc) and extract a valid query + aggregation from it in order to be able to run it via the ES api.
Looking at the exported object, i can see searchSourceJSON and visState which hold the query and agg but the format is not a ready Lucene query.

I know there’s no built-in capability for this but i kindly ask if you can direct me to the relevant functions in the code to use?


Any update please? couldn’t find a solution yet