Like, what's the difference between the kibana API and the elasticsearch API?
There is no Kibana API, so I'm not sure what you're asking. All communication happens against Elasticsearch. As mentioned in that tutorial, you'll likely want to use server.plugins.elasticsearch.callWithRequest
to do that communication. All callWithRequest
does is take the request object, and use it to talk to Elasticsearch. This is useful and important to be able to enforce authentication.
Will I be able to perform complex queries (using aggregates, multiple conditions, grouping and ordering) now that I'm using a custom plugin?
Yes, callWithRequest
is basically a passthrough for the javascript Elasticsearch client (which passes along auth data, as mentioned). So anything you can do with that library, you can do with that helper. You can also write custom methods that you can plug in to the client, but I'll tell you from experience that that part of it is tricky to understand (I still don't get it myself).
As an example, from that tutorial, server.plugins.elasticsearch.callWithRequest(req, 'cluster.state', {...})
is calling the cluster.state method and the object as the 3rd argument gets passed to that method as the params
. Anything in the ES-JS client can be used this way, and the API docs there are pretty thorough.
As for accessing the timepicker data... I don't know offhand. I'll admit I've only ever written APIs and other functionality as plugins, I've never tried to build a visualization. Most visualizations simply use the "courier", which is an abstract way to query Elasticsearch, something I've learned a little in the past, but no longer understand. I believe the courier takes the timepicker value into account, so if you use something else, you have to pull that value yourself.
I dug through and got a little guidance, and learned that there's a timepicker service that provides that information. The new time series visualizations do this, and you can see the code that does it here: https://github.com/elastic/kibana/blob/master/src/core_plugins/metrics/public/kbn_vis_types/request_handler.js