Query field in request sent to elasticsearch

Hi,
I'm developing a Kibana plugin. How can I get in my code the payload from a request that is sent to elastic search (it is shown in the Inspect => Request UI). I need the query field.

Hi,

You will have to connect to ES using http and APIs -
https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html

Hope this helps
Thanks,
Bhavya

Hi. I do not want to send a query to es. I want to get by code what kibana sends to es (for example, when adding a filter to the discover page). It is shown in the inspect panel but how do i get it through the code to use in my plugin. I am coding in the hack file.

I am trying to import editor_registry.ts in my hack file:
import { instance as registry } from 'core_plugins/console/np_ready/application/contexts/editor_context/editor_registry';

This does not work. How should I import it? I am using Kibana 7.6.1.
I'm trying to do the following code:
const editor = registry.getInputEditor();
const requests = await editor.getRequestsInRange();