This code requires some setup on the SQL Server/db side to store the Query to run on Elasticsearch and it dynamically replaces parts of the query based on input params.
There is also a scroll handling mechanism for multiple page results and allows password encryption/decryption to avoid storing password in full view.
Here’s the code: