Get _msearch request payload kibana custom plugin

(jetpumz) #1

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) {
    config: {
      cors: {
        origin: ['*'],
    path: '/export',
    method: 'POST',
    handler: async (req, reply) => {
      const dataCluster = server.plugins.elasticsearch.getCluster('data');
      dataCluster.callWithRequest(req, 'search').then(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 ?

(Peter Pisljar) #2

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

thank you.

(jetpumz) #3

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

(Peter Pisljar) #4

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

(jetpumz) #5

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

(Peter Pisljar) #6

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:

I hope this is helpful, regards, Peter

(jetpumz) #7

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

(system) #8

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