kibana/docs/extend/elasticsearch-service.md
Colleen McGinnis 1814c60017
[docs] Migrate docs from AsciiDoc to Markdown (#212558)
Migrate docs from AsciiDoc to Markdown. The preview can be built after
#212557 is merged.

@florent-leborgne please tag reviewers, add the appropriate label(s),
and take this out of draft when you're ready.

Note: More files are deleted than added here because the content from
some files was moved to
[elastic/docs-content](https://github.com/elastic/docs-content).

**What has moved to
[elastic/docs-content](https://github.com/elastic/docs-content)?**

Public-facing narrative and conceptual docs have moved. Most can now be
found under the following directories in the new docs:
- explore-analyze: Discover, Dashboards, Visualizations, Reporting,
Alerting, dev tools...
- deploy-manage: Stack management (Spaces, user management, remote
clusters...)
- troubleshooting: .... troubleshooting pages

**What is staying in the Kibana repo?**

- Reference content (= anything that is or could be auto-generated):
Settings, syntax references
- Release notes
- Developer guide

---------

Co-authored-by: Florent Le Borgne <florent.leborgne@elastic.co>
2025-03-04 14:56:07 +01:00

34 lines
1.3 KiB
Markdown

---
mapped_pages:
- https://www.elastic.co/guide/en/kibana/current/elasticsearch-service.html
---
# Elasticsearch service [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 [Data plugin](https://github.com/elastic/kibana/blob/master/src/platform/plugins/shared/data/README.mdx).
::::
`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](/extend/patterns.md#scoped-services) and [Security](/extend/development-security.md).
```typescript
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 [Global search plugin](https://github.com/elastic/kibana/blob/master/x-pack/platform/plugins/shared/global_search/README.md).