Get _msearch request payload kibana custom plugin

So I'm trying to build a csv export feature for discover on kibana 5.5.1, I'm trying to fetch all the data from elasticsearch on backend using

export default function (server) {
  server.route({
    config: {
      cors: {
        origin: ['*'],
      }
    },
    path: '/export',
    method: 'POST',
    handler: async (req, reply) => {
      const dataCluster = server.plugins.elasticsearch.getCluster('data');
      dataCluster.callWithRequest(req, 'search').then(res => {
        console.log(res);
      });
    }
  });

}

The thing is now I'm stuck on how to inject the request payload that kibana use in _msearch REST API so that I can inject it to backend. Anyone ?

i don't fully understand the question, could you try explaining a bit more on what you are trying to achieve ?

thank you.

Hi @ppisljar, thanks for the response !

So if you see at the picutre, I want to get the request payload dynamically that kibana sent to _msearch REST API from my custom plugin

how do you send the request to _msearch to kibana inside your custom plugin ? do you use SearchSource ?

That's exactly my question, I'm not sure how to do it @ppisljar Is that a kibana service ?

we don't have any documentation on that so i would suggest to look into the SearchSource source code (at /src/ui/public/courier/data_source/)

you can also take a look at this PR: where i am creating a new search source and then getting the response back: https://github.com/elastic/kibana/pull/15525

I hope this is helpful, regards, Peter

@ppisljar This is more than enough, thanks so much !

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.