Accessing to different index from the contoroller in kibana

Hi!

I am now writing code for custom plugin in kibana.

What I want to do is, access to different index from the current scope.

I have a controller for visualization app accessing to index1 now as below .

  module.controller('PluginController', function ($scope, Private) {
      $scope.$watch('esResponse', function (resp) {
        if (resp) {
         var bucketId = $scope.vis.aggs.bySchemaName['bucket'][0].id;

         var buckets  = resp.aggregations[bucketId].buckets;

         $scope.bucket = buckets.map(function(bucket)) {
           return {
             label: bucket.key
           };
         };
        }
      });
    });

But I want to access to index test2 too in my custom logic.
Is this possible in visualization app?

It's not very clear what your goals are. Seems that you access index1 because that's the selected index pattern for your visualization, but is the index2 name supposed to be hardcoded in your controller for a follow-up query? Is the goal going to be to join data from the initial response with data from index2?

Hi @tsullivan

Sorry that I didnt make things clear.

What I want to do is to access index1 and index2 regardless of selected index in vidualization.

I assume this is possible using javascript client of elasticsearch.

https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html

Am I correct?

Am I correct?

Yes, you should be able to get the Elasticsearch client by creating a module that has the es dependency, which is the Elasticsearch client. An example from Kibana: https://github.com/elastic/kibana/blob/v4.5.4/src/ui/public/courier/fetch/_call_client.js#L2

Then you can call methods off the client, for example es.get(). You can refer to the documentation for the available methods and the options they take. Index name is usually a field you can supply in the params.

Sorry for the delayed response - my email notifications were not coming in.