How to get content of document in Kibana plugin


#1

Preformatted textHi, I'm developing custom kibana plugin, and try to retrieve document using the Elasticsearch JS method "GET", but get nothing. I have some questions about how to fetch content from the "response", and my code is like this.

  server.route({
    path : '/api/log-analysis/data',
    method: ['POST', 'GET'],
    handler: function(request, reply){
      const { callWithRequest } = server.plugins.elasticsearch.getCluster('data');
      callWithRequest(request, 'get', {
        index: '[my index]',
        type: '[my type]',
        id:  '[my id]'
      }).then(function(response){
        reply(response.data);
      });
    }
  });

Can anyone give me some advice? Thanks!


(Archana ) #2

Hi,

Let's troubleshoot why you're getting nothing back. Is the response empty? Or response.data? I would also check Elasticsearch logs to see activity, and whether there's an error given back. You can also catch errors in your handler.


#3

Thanks for your advice, I do get more information. The response.data is null and the response is not null. There are no errors given back. I think I may set the parameters wrong, and I'm trying to fix it. Could you let me know if you have more suggestions, thanks. :slight_smile:


(system) #4

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