Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 1.11 KB

elasticsearch-service.asciidoc

File metadata and controls

28 lines (21 loc) · 1.11 KB

Elasticsearch service

Elasticsearch service provides elasticsearch.client program API to communicate with Elasticsearch server HTTP API.

Note
The Elasticsearch service is only available server side. You can use the {kib-repo}blob/{branch}/src/plugins/data/README.mdx[Data plugin].

elasticsearch.client interacts with Elasticsearch service on behalf of:

  • kibana_system user via elasticsearch.client.asInternalUser.* methods.

  • a current end-user via elasticsearch.client.asCurrentUser.* methods. In this case Elasticsearch client should be given the current user credentials. See [scoped-services] and [development-security].

import { CoreStart, Plugin } from '@kbn/core/public';

export class MyPlugin implements Plugin {
  public start(core: CoreStart) {
    async function asyncTask() {
      const result = await core.elasticsearch.client.asInternalUser.ping();
    }
    asyncTask();
  }
}

For advanced use-cases, such as a search for specific objects, use the {kib-repo}blob/{branch}/x-pack/plugins/global_search/README.md[Global search plugin].