From 47cdb28f2c7db48d4fabaebb51e7cd352947ab64 Mon Sep 17 00:00:00 2001 From: Anan <79961084+ananzh@users.noreply.github.com> Date: Thu, 5 Aug 2021 12:58:58 -0700 Subject: [PATCH] clean up docs folder (#105) Issue Resolved: https://github.com/opensearch-project/opensearch-js/issues/104 Signed-off-by: Anan Zhuang --- docs/advanced-config.asciidoc | 100 - docs/basic-config.asciidoc | 258 - docs/breaking-changes.asciidoc | 334 - docs/changelog.asciidoc | 756 -- docs/child.asciidoc | 33 - docs/configuration.asciidoc | 12 - docs/connecting.asciidoc | 532 -- docs/extend.asciidoc | 72 - docs/helpers.asciidoc | 579 -- docs/index.asciidoc | 23 - docs/installation.asciidoc | 94 - docs/integrations.asciidoc | 8 - docs/introduction.asciidoc | 195 - docs/observability.asciidoc | 428 -- docs/redirects.asciidoc | 9 - docs/reference.asciidoc | 11995 ------------------------------- docs/testing.asciidoc | 157 - docs/transport.asciidoc | 34 - docs/typescript.asciidoc | 277 - 19 files changed, 15896 deletions(-) delete mode 100644 docs/advanced-config.asciidoc delete mode 100644 docs/basic-config.asciidoc delete mode 100644 docs/breaking-changes.asciidoc delete mode 100644 docs/changelog.asciidoc delete mode 100644 docs/child.asciidoc delete mode 100644 docs/configuration.asciidoc delete mode 100644 docs/connecting.asciidoc delete mode 100644 docs/extend.asciidoc delete mode 100644 docs/helpers.asciidoc delete mode 100644 docs/index.asciidoc delete mode 100644 docs/installation.asciidoc delete mode 100644 docs/integrations.asciidoc delete mode 100644 docs/introduction.asciidoc delete mode 100644 docs/observability.asciidoc delete mode 100644 docs/redirects.asciidoc delete mode 100644 docs/reference.asciidoc delete mode 100644 docs/testing.asciidoc delete mode 100644 docs/transport.asciidoc delete mode 100644 docs/typescript.asciidoc diff --git a/docs/advanced-config.asciidoc b/docs/advanced-config.asciidoc deleted file mode 100644 index 1308b806a..000000000 --- a/docs/advanced-config.asciidoc +++ /dev/null @@ -1,100 +0,0 @@ -[[advanced-config]] -=== Advanced configuration - -If you need to customize the client behavior heavily, you are in the right -place! The client enables you to customize the following internals: - -* `ConnectionPool` class -* `Connection` class -* `Serializer` class - -NOTE: For information about the `Transport` class, refer to <>. - - -[discrete] -==== `ConnectionPool` - -This class is responsible for keeping in memory all the {es} Connection that you -are using. There is a single Connection for every node. The connection pool -handles the resurrection strategies and the updates of the pool. - -[source,js] ----- -const { Client, ConnectionPool } = require('@elastic/elasticsearch') - -class MyConnectionPool extends ConnectionPool { - markAlive (connection) { - // your code - super.markAlive(connection) - } -} - -const client = new Client({ - ConnectionPool: MyConnectionPool -}) ----- - - -[discrete] -==== `Connection` - -This class represents a single node, it holds every information we have on the -node, such as roles, id, URL, custom headers and so on. The actual HTTP request -is performed here, this means that if you want to swap the default HTTP client -(Node.js core), you should override the `request` method of this class. - -[source,js] ----- -const { Client, Connection } = require('@elastic/elasticsearch') - -class MyConnection extends Connection { - request (params, callback) { - // your code - } -} - -const client = new Client({ - Connection: MyConnection -}) ----- - - -[discrete] -==== `Serializer` - -This class is responsible for the serialization of every request, it offers the -following methods: - -* `serialize(object: any): string;` serializes request objects. -* `deserialize(json: string): any;` deserializes response strings. -* `ndserialize(array: any[]): string;` serializes bulk request objects. -* `qserialize(object: any): string;` serializes request query parameters. - -[source,js] ----- -const { Client, Serializer } = require('@elastic/elasticsearch') - -class MySerializer extends Serializer { - serialize (object) { - // your code - } -} - -const client = new Client({ - Serializer: MySerializer -}) ----- - -[discrete] -==== Migrate to v8 - -The Node.js client can be configured to emit an HTTP header -``Accept: application/vnd.elasticsearch+json; compatible-with=7`` -which signals to Elasticsearch that the client is requesting -``7.x`` version of request and response bodies. This allows for -upgrading from 7.x to 8.x version of Elasticsearch without upgrading -everything at once. Elasticsearch should be upgraded first after -the compatibility header is configured and clients should be upgraded -second. -To enable to setting, configure the environment variable -``ELASTIC_CLIENT_APIVERSIONING`` to ``true``. diff --git a/docs/basic-config.asciidoc b/docs/basic-config.asciidoc deleted file mode 100644 index 04e95ca9e..000000000 --- a/docs/basic-config.asciidoc +++ /dev/null @@ -1,258 +0,0 @@ -[[basic-config]] -=== Basic configuration - -This page shows you the possible basic configuration options that the clients -offers. - - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') - -const client = new Client({ - node: 'http://localhost:9200', - maxRetries: 5, - requestTimeout: 60000, - sniffOnStart: true -}) ----- - - -[cols=2*] -|=== -|`node` or `nodes` -a|The Elasticsearch endpoint to use. + -It can be a single string or an array of strings: -[source,js] ----- -node: 'http://localhost:9200' ----- -Or it can be an object (or an array of objects) that represents the node: -[source,js] ----- -node: { - url: new URL('http://localhost:9200'), - ssl: 'ssl options', - agent: 'http agent options', - id: 'custom node id', - headers: { 'custom': 'headers' } - roles: { - master: true, - data: true, - ingest: true, - ml: false - } -} ----- - -|`auth` -a|Your authentication data. You can use both basic authentication and -{ref}/security-api-create-api-key.html[ApiKey]. + -See https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/auth-reference.html[Authentication] -for more details. + -_Default:_ `null` - -Basic authentication: -[source,js] ----- -auth: { - username: 'elastic', - password: 'changeme' -} ----- -{ref}/security-api-create-api-key.html[ApiKey] authentication: -[source,js] ----- -auth: { - apiKey: 'base64EncodedKey' -} ----- -Bearer authentication, useful for https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-service-token.html[service account tokens]. Be aware that it does not handle automatic token refresh: -[source,js] ----- -auth: { - bearer: 'token' -} ----- - - -|`maxRetries` -|`number` - Max number of retries for each request. + -_Default:_ `3` - -|`requestTimeout` -|`number` - Max request timeout in milliseconds for each request. + -_Default:_ `30000` - -|`pingTimeout` -|`number` - Max ping request timeout in milliseconds for each request. + -_Default:_ `3000` - -|`sniffInterval` -|`number, boolean` - Perform a sniff operation every `n` milliseconds. Sniffing might not be the best solution for you, take a look https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how[here] to know more. + -_Default:_ `false` - -|`sniffOnStart` -|`boolean` - Perform a sniff once the client is started. Sniffing might not be the best solution for you, take a look https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how[here] to know more. + -_Default:_ `false` - -|`sniffEndpoint` -|`string` - Endpoint to ping during a sniff. + -_Default:_ `'_nodes/_all/http'` - -|`sniffOnConnectionFault` -|`boolean` - Perform a sniff on connection fault. Sniffing might not be the best solution for you, take a look https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how[here] to know more. + -_Default:_ `false` - -|`resurrectStrategy` -|`string` - Configure the node resurrection strategy. + -_Options:_ `'ping'`, `'optimistic'`, `'none'` + -_Default:_ `'ping'` - -|`suggestCompression` -|`boolean` - Adds `accept-encoding` header to every request. + -_Default:_ `false` - -|`compression` -|`string, boolean` - Enables gzip request body compression. + -_Options:_ `'gzip'`, `false` + -_Default:_ `false` - -|`ssl` -|`http.SecureContextOptions` - ssl https://nodejs.org/api/tls.html[configuraton]. + -_Default:_ `null` - -|`proxy` -a|`string, URL` - If you are using an http(s) proxy, you can put its url here. -The client will automatically handle the connection to it. + -_Default:_ `null` -[source,js] ----- -const client = new Client({ - node: 'http://localhost:9200', - proxy: 'http://localhost:8080' -}) - -// Proxy with basic authentication -const client = new Client({ - node: 'http://localhost:9200', - proxy: 'http://user:pwd@localhost:8080' -}) ----- - -|`agent` -a|`http.AgentOptions, function` - http agent https://nodejs.org/api/http.html#http_new_agent_options[options], -or a function that returns an actual http agent instance. If you want to disable the http agent use entirely -(and disable the `keep-alive` feature), set the agent to `false`. + -_Default:_ `null` -[source,js] ----- -const client = new Client({ - node: 'http://localhost:9200', - agent: { agent: 'options' } -}) - -const client = new Client({ - node: 'http://localhost:9200', - // the function takes as parameter the option - // object passed to the Connection constructor - agent: (opts) => new CustomAgent() -}) - -const client = new Client({ - node: 'http://localhost:9200', - // Disable agent and keep-alive - agent: false -}) ----- - -|`nodeFilter` -a|`function` - Filters which node not to use for a request. + -_Default:_ -[source,js] ----- -function defaultNodeFilter (node) { - // avoid master only nodes - if (node.roles.master === true && - node.roles.data === false && - node.roles.ingest === false) { - return false - } - return true -} ----- - -|`nodeSelector` -a|`function` - custom selection strategy. + -_Options:_ `'round-robin'`, `'random'`, custom function + -_Default:_ `'round-robin'` + -_Custom function example:_ -[source,js] ----- -function nodeSelector (connections) { - const index = calculateIndex() - return connections[index] -} ----- - -|`generateRequestId` -a|`function` - function to generate the request id for every request, it takes -two parameters, the request parameters and options. + -By default it generates an incremental integer for every request. + -_Custom function example:_ -[source,js] ----- -function generateRequestId (params, options) { - // your id generation logic - // must be syncronous - return 'id' -} ----- - -|`name` -|`string, symbol` - The name to identify the client instance in the events. + -_Default:_ `elasticsearch-js` - -|`opaqueIdPrefix` -|`string` - A string that will be use to prefix any `X-Opaque-Id` header. + -See https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/observability.html#_x-opaque-id_support[`X-Opaque-Id` support] for more details. + -_Default:_ `null` - -|`headers` -|`object` - A set of custom headers to send in every request. + -_Default:_ `{}` - -|`context` -|`object` - A custom object that you can use for observability in your events. -It will be merged with the API level context option. + -_Default:_ `null` - -|`enableMetaHeader` -|`boolean` - If true, adds an header named `'x-elastic-client-meta'`, containing some minimal telemetry data, -such as the client and platform version. + -_Default:_ `true` - -|`cloud` -a|`object` - Custom configuration for connecting to -https://cloud.elastic.co[Elastic Cloud]. See https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/auth-reference.html[Authentication] -for more details. + -_Default:_ `null` + -_Cloud configuration example:_ -[source,js] ----- -const client = new Client({ - cloud: { - id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==' - }, - auth: { - username: 'elastic', - password: 'changeme' - } -}) ----- - -|`disablePrototypePoisoningProtection` -|`boolean`, `'proto'`, `'constructor'` - By the default the client will protect you against prototype poisoning attacks. Read https://web.archive.org/web/20200319091159/https://hueniverse.com/square-brackets-are-the-enemy-ff5b9fd8a3e8?gi=184a27ee2a08[this article] to learn more. If needed you can disable prototype poisoning protection entirely or one of the two checks. Read the `secure-json-parse` https://github.com/fastify/secure-json-parse[documentation] to learn more. + -_Default:_ `false` - -|=== diff --git a/docs/breaking-changes.asciidoc b/docs/breaking-changes.asciidoc deleted file mode 100644 index 9942eb9a8..000000000 --- a/docs/breaking-changes.asciidoc +++ /dev/null @@ -1,334 +0,0 @@ -[[breaking-changes]] -=== Breaking changes coming from the old client - -If you were already using the previous version of this client – the one you used -to install with `npm install elasticsearch` – you will encounter some breaking -changes. - - -[discrete] -==== Don’t panic! - -Every breaking change was carefully weighed, and each is justified. Furthermore, -the new codebase has been rewritten with modern JavaScript and has been -carefully designed to be easy to maintain. - - -[discrete] -==== Breaking changes - -* Minimum supported version of Node.js is `v8`. - -* Everything has been rewritten using ES6 classes to help users extend the -defaults more easily. - -* There is no longer an integrated logger. The client now is an event emitter -that emits the following events: `request`, `response`, and `error`. - -* The code is no longer shipped with all the versions of the API, but only that -of the package’s major version. This means that if you are using {es} `v6`, you -are required to install `@elastic/elasticsearch@6`, and so on. - -* The internals are completely different, so if you used to tweak them a lot, -you will need to refactor your code. The public API should be almost the same. - -* There is no longer browser support, for that will be distributed via another -module: `@elastic/elasticsearch-browser`. This module is intended for Node.js -only. - -* The returned value of an API call will no longer be the `body`, `statusCode`, -and `headers` for callbacks, and only the `body` for promises. The new returned -value will be a unique object containing the `body`, `statusCode`, `headers`, -`warnings`, and `meta`, for both callback and promises. - - -[source,js] ----- -// before -const body = await client.search({ - index: 'my-index', - body: { foo: 'bar' } -}) - -client.search({ - index: 'my-index', - body: { foo: 'bar' } -}, (err, body, statusCode, headers) => { - if (err) console.log(err) -}) - -// after -const { body, statusCode, headers, warnings } = await client.search({ - index: 'my-index', - body: { foo: 'bar' } -}) - -client.search({ - index: 'my-index', - body: { foo: 'bar' } -}, (err, { body, statusCode, headers, warnings }) => { - if (err) console.log(err) -}) ----- - - -* Errors: there is no longer a custom error class for every HTTP status code -(such as `BadRequest` or `NotFound`). There is instead a single `ResponseError`. -Every error class has been renamed, and now each is suffixed with `Error` at the -end. - -* Removed errors: `RequestTypeError`, `Generic`, and all the status code -specific errors (such as `BadRequest` or `NotFound`). - -* Added errors: `ConfigurationError` (in case of bad configurations) and -`ResponseError` that contains all the data you may need to handle the specific -error, such as `statusCode`, `headers`, `body`, and `message`. - - -* Renamed errors: - -** `RequestTimeout` (408 statusCode) => `TimeoutError` -** `ConnectionFault` => `ConnectionError` -** `NoConnections` => `NoLivingConnectionsError` -** `Serialization` => `SerializationError` -** `Serialization` => `DeserializationError` - -* You must specify the port number in the configuration. In the previous -version, you can specify the host and port in a variety of ways. With the new -client, there is only one way to do it, via the `node` parameter. - -* Certificates are verified by default, if you want to disable certificates verification, you should set the `rejectUnauthorized` option to `false` inside the `ssl` configuration: - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ - ssl: { rejectUnauthorized: false } -}) ----- - -* The `plugins` option has been removed. If you want to extend the client now, -you should use the `client.extend` API. - -[source,js] ----- -// before -const { Client } = require('elasticsearch') -const client = new Client({ plugins: [...] }) - -// after -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ ... }) -client.extend(...) ----- - -* There is a clear distinction between the API related parameters and the client -related configurations. The parameters `ignore`, `headers`, `requestTimeout` and -`maxRetries` are no longer part of the API object and you need to specify them -in a second option object. - -[source,js] ----- -// before -const body = await client.search({ - index: 'my-index', - body: { foo: 'bar' }, - ignore: [404] -}) - -client.search({ - index: 'my-index', - body: { foo: 'bar' }, - ignore: [404] -}, (err, body, statusCode, headers) => { - if (err) console.log(err) -}) - -// after -const { body, statusCode, headers, warnings } = await client.search({ - index: 'my-index', - body: { foo: 'bar' } -}, { - ignore: [404] -}) - -client.search({ - index: 'my-index', - body: { foo: 'bar' } -}, { - ignore: [404] -}, (err, { body, statusCode, headers, warnings }) => { - if (err) console.log(err) -}) ----- - -* The `transport.request` method no longer accepts the `query` key. Use the -`querystring` key instead (which can be a string or an object). You also -need to send a bulk-like request instead of the `body` key, use the `bulkBody` -key. In this method, the client specific parameters should be passed as a second -object. - -[source,js] ----- -// before -const body = await client.transport.request({ - method: 'GET', - path: '/my-index/_search', - body: { foo: 'bar' }, - query: { bar: 'baz' } - ignore: [404] -}) - -client.transport.request({ - method: 'GET', - path: '/my-index/_search', - body: { foo: 'bar' }, - query: { bar: 'baz' } - ignore: [404] -}, (err, body, statusCode, headers) => { - if (err) console.log(err) -}) - -// after -const { body, statusCode, headers, warnings } = await client.transport.request({ - method: 'GET', - path: '/my-index/_search', - body: { foo: 'bar' }, - querystring: { bar: 'baz' } -}, { - ignore: [404] -}) - -client.transport.request({ - method: 'GET', - path: '/my-index/_search', - body: { foo: 'bar' }, - querystring: { bar: 'baz' } -}, { - ignore: [404] -}, (err, { body, statusCode, headers, warnings }) => { - if (err) console.log(err) -}) ----- - -[discrete] -==== Talk is cheap. Show me the code. - -You can find a code snippet with the old client below followed by the same code -logic but with the new client. - -[source,js] ----- -const { Client, errors } = require('elasticsearch') -const client = new Client({ - host: 'http://localhost:9200', - plugins: [utility] -}) - -async function run () { - try { - const body = await client.search({ - index: 'game-of-thrones', - body: { - query: { - match: { quote: 'winter' } - } - } - ignore: [404] - }) - console.log(body) - } catch (err) { - if (err instanceof errors.BadRequest) { - console.log('Bad request') - } else { - console.log(err) - } - } -} - -function utility (Client, config, components) { - const ca = components.clientAction.factory - Client.prototype.utility = components.clientAction.namespaceFactory() - const utility = Client.prototype.utility.prototype - - utility.index = ca({ - params: { - refresh: { - type: 'enum', - options: [ - 'true', - 'false', - 'wait_for', - '' - ] - }, - }, - urls: [ - { - fmt: '/<%=index%>/_doc', - req: { - index: { - type: 'string', - required: true - } - } - } - ], - needBody: true, - method: 'POST' - }) -}) ----- - -And now with the new client. - -[source,js] ----- -const { Client, errors } = require('@elastic/elasticsearch') -// NOTE: `host` has been renamed to `node`, -// and `plugins` is no longer supported -const client = new Client({ node: 'http://localhost:9200' }) - -async function run () { - try { - // NOTE: we are using the destructuring assignment - const { body } = await client.search({ - index: 'game-of-thrones', - body: { - query: { - match: { quote: 'winter' } - } - } - // NOTE: `ignore` now is in a separated object - }, { - ignore: [404] - }) - console.log(body) - } catch (err) { - // NOTE: we are checking the `statusCode` property - if (err.statusCode === 400) { - console.log('Bad request') - } else { - console.log(err) - } - } -} - -// NOTE: we can still extend the client, but with a different API. -// This new API is a little bit more verbose, since you must write -// your own validations, but it's way more flexible. -client.extend('utility.index', ({ makeRequest, ConfigurationError }) => { - return function utilityIndex (params, options) { - const { body, index, ...querystring } = params - if (body == null) throw new ConfigurationError('Missing body') - if (index == null) throw new ConfigurationError('Missing index') - const requestParams = { - method: 'POST', - path: `/${index}/_doc`, - body: body, - querystring - } - return makeRequest(requestParams, options) - } -}) ----- diff --git a/docs/changelog.asciidoc b/docs/changelog.asciidoc deleted file mode 100644 index c8a598938..000000000 --- a/docs/changelog.asciidoc +++ /dev/null @@ -1,756 +0,0 @@ -[[changelog-client]] -== Release notes - -[discrete] -=== 7.13.0 - -[discrete] -==== Breaking changes - -[discrete] -===== Remove Node.js v10 support https://github.com/elastic/elasticsearch-js/pull/1471[#1471] - -According to our -https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/installation.html#nodejs-support[support matrix]. - -[discrete] -==== Features - -[discrete] -===== Support for Elasticsearch `v7.13` - -You can find all the API changes -https://www.elastic.co/guide/en/elasticsearch/reference/7.13/release-notes-7.13.0.html[here]. - -[discrete] -===== Added new TypeScript definitions - -The new type definition is more advanced compared to the legacy one. -In the legacy type definitions you were expected to configure via generics both request and response bodies. -The new type definitions comes with a complete type definition for every Elasticsearch endpoint. - -You can see how to use them now https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/typescript.html[here]. - -[discrete] -===== Improve response error message https://github.com/elastic/elasticsearch-js/pull/1457[#1457] - -In case of Elasticsearch errors, now the error message show more info about the underlying issue, -improving the debugging experience. - - -[discrete] -==== Fixes - -[discrete] -===== Catch HEAD errors https://github.com/elastic/elasticsearch-js/pull/1460[#1460] - -In case of http errors in HEAD request, the client was swalling the response body. -This is now fixed and in case of error you will get the full body response. - -[discrete] -=== 7.12.0 - -[discrete] -==== Breaking changes - -[discrete] -===== Remove Node.js v8 support https://github.com/elastic/elasticsearch-js/pull/1402[#1402] - -According to our -https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/installation.html#nodejs-support[support matrix]. - -[discrete] -==== Features - -[discrete] -===== Support for Elasticsearch `v7.12` - -You can find all the API changes -https://www.elastic.co/guide/en/elasticsearch/reference/7.12/release-notes-7.12.0.html[here]. - -[discrete] -===== Add support for transport options to all helpers https://github.com/elastic/elasticsearch-js/pull/1400[#1400] - -You can now pass Transport specific options to the helpers as well. - -[discrete] -==== Fixes - -[discrete] -===== Add `.finally` method to the Promise API https://github.com/elastic/elasticsearch-js/pull/1415[#1415] - -The client returns a thenable object when you are not configuring a callback. -Now the thenable offers a `.finally` method as well. - -[discrete] -=== 7.11.0 - -[discrete] -==== Features - -[discrete] -===== Support for Elasticsearch `v7.11` - -You can find all the API changes -https://www.elastic.co/guide/en/elasticsearch/reference/7.11/release-notes-7.11.0.html[here]. - -[discrete] -===== Added new observability events https://github.com/elastic/elasticsearch-js/pull/1365[#1365] - -Two new observability events has been introduced: `serialization` and -`deserialization`. The event order is described in the following graph, in some -edge cases, the order is not guaranteed. You can find in -https://github.com/elastic/elasticsearch-js/blob/master/test/acceptance/events-order.test.js[`test/acceptance/events-order.test.js`] -how the order changes based on the situation. - ----- -serialization - │ - │ (serialization and compression happens between those two events) - │ - └─▶ request - │ - │ (actual time spent over the wire) - │ - └─▶ deserialization - │ - │ (deserialization and decompression happens between those two events) - │ - └─▶ response ----- - -[discrete] -===== Added x-elastic-client-meta header https://github.com/elastic/elasticsearch-js/pull/1373[#1373] - -Adds the `x-elastic-client-meta` HTTP header which is used by Elastic Cloud and -can be disabled with the `enableMetaHeader` parameter set to `false`. - -[discrete] -==== Fixes - -[discrete] -===== Fixes req.abort() with a body that is a stream calls callback(err) twice https://github.com/elastic/elasticsearch-js/pull/1376[#1376] - -When using a body that is a stream to client.search(), and calling req.abort(), -the callback is called twice. Once for the RequestAbortedError, as expected, and -once for a "premature close" error from end-of-stream, used by pump, used by the -client. This issue has now been fixed. - -[discrete] -=== 7.10.0 - -[discrete] -==== Features - -[discrete] -===== Support for Elasticsearch `v7.10`. - -You can find all the API changes -https://www.elastic.co/guide/en/elasticsearch/reference/7.10/release-notes-7.10.0.html[here]. - -[discrete] -===== Added proxy support https://github.com/elastic/elasticsearch-js/pull/1260[#1260] - -If you need to pass through an http(s) proxy for connecting to {es}, the client -offers out of the box a handy configuration for helping you with it. Under the -hood it uses the https://github.com/delvedor/hpagent[`hpagent`] module. - -[source,js] ----- -const client = new Client({ - node: 'http://localhost:9200', - proxy: 'http://localhost:8080' -}) ----- - -Basic authentication is supported as well: - -[source,js] ----- -const client = new Client({ - node: 'http://localhost:9200', - proxy: 'http://user:pwd@localhost:8080' -}) ----- - -[discrete] -==== Fixes - -[discrete] -===== Scroll search should clear the scroll at the end https://github.com/elastic/elasticsearch-js/pull/1331[#1331] - -From now on the scroll search helper will automatically close the scroll on -{es}, by doing so, {es} will free resources faster. - -[discrete] -===== Handle connectivity issues while reading the body https://github.com/elastic/elasticsearch-js/pull/1343[#1343] - -It might happen that the underlying socket stops working due to an external -cause while reading the body. This could lead to an unwanted -`DeserialzationError`. From now, this will be handled as a generic -`ConnectionError`. - -[discrete] -==== Warnings - -[discrete] -===== Add warning log about nodejs version support https://github.com/elastic/elasticsearch-js/pull/1349[#1349] - -`7.11` will be the last version of the client that will support Node.js v8, -while `7.12` will be the last one that supports Node.js v10. If you are eusing -this versions you will see a `DeprecationWaring` in your logs. We strongly -recommend to upgrade to newer versions of Node.js as usng an EOL version will -expose you to securty risks. - -Please refer to https://ela.st/nodejs-support[ela.st/nodejs-support] for -additional information. - -[discrete] -=== 7.9.1 - -[discrete] -==== Fixes - -[discrete] -===== Improve child performances https://github.com/elastic/elasticsearch-js/pull/1314[#1314] - -The client code has been refactored to speed up the performances of the child -method. Before this pr, creating many children per second would have caused a -high memory consumption and a spike in CPU usage. This pr changes the way the -client is created by refactoring the code generation, now the clients methods -are no longer added to the instance with a for loop but via prototypal -inheritance. Thus, the overall performances are way better, now creating a child -is ~5 times faster, and it consumes ~70% less memory. - -This change should not cause any breaking change unless you were mocking the -client methods. In such case you should refactor it, or use -https://github.com/elastic/elasticsearch-js-mock[elasticsearch-js-mock]. - -Finally, this change should also fix once and of all the bundlers support. - -[discrete] -===== Throw all errors asynchronously https://github.com/elastic/elasticsearch-js/pull/1295[#1295] - -Some validation errors were thrown synchronously, causing the callback to be -called in th same tick. This issue is known as _"The release fo Zalgo"_ (see -https://blog.izs.me/2013/08/designing-apis-for-asynchrony[here]). - -[discrete] -===== Fix `maxRetries` request option handling https://github.com/elastic/elasticsearch-js/pull/1296[#1296] - -The `maxRetries` parameter can be configured on a per requets basis, if set to -zero it was defaulting to the client default. Now the client is honoring the -request specific configuration. - -[discrete] -===== Fix RequestOptions.body type to include null https://github.com/elastic/elasticsearch-js/pull/1300[#1300] - -The Connection requets option types were not accepting `null` as valid value. - -[discrete] -===== Fixed `size` and `maxRetries` parameters in helpers https://github.com/elastic/elasticsearch-js/pull/1284[#1284] - -The `size` parameter was being passed too the scroll request, which was causing -an error. Value of `maxRetries` set to 0 was resulting in no request at all. - -[discrete] -=== 7.9.0 - -[discrete] -==== Features - -[discrete] -===== Add ability to disable the http agent https://github.com/elastic/elasticsearch-js/pull/1251[#1251] - -If needed, the http agent can be disabled by setting it to `false`. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ - node: 'http://localhost:9200'. - agent: false -}) ----- - -[discrete] -===== Add support for a global context option https://github.com/elastic/elasticsearch-js/pull/1256[#1256] - -Before this, you could set a `context` option in each request, but there was no -way of setting it globally. Now you can by configuring the `context` object in -the global configuration, that will be merged with the local one. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ - node: 'http://localhost:9200'. - context: { meta: 'data' } -}) ----- - -[discrete] -===== ESM support https://github.com/elastic/elasticsearch-js/pull/1235[#1235] - -If you are using ES Modules, now you can easily import the client! - -[source,js] ----- -import { Client } from '@elastic/elasticsearch' ----- - -[discrete] -==== Fixes - -[discrete] -===== Allow the client name to be a symbol https://github.com/elastic/elasticsearch-js/pull/1254[#1254] - -It was possible in plain JavaScript, but not in TypeScript, now you can do it in -TypeScript as well. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ - node: 'http://localhost:9200', - name: Symbol('unique') -}) ----- - -[discrete] -===== Fixed transport.request querystring type https://github.com/elastic/elasticsearch-js/pull/1240[#1240] - -Only `Record` was allowed. Now `string` is allowed as well. - -[discrete] -===== Fixed type definitions https://github.com/elastic/elasticsearch-js/pull/1263[#1263] - -* The `transport.request` defintion was incorrect, it was returning a - `Promise` instead of `TransportRequestPromise`. -* The `refresh` parameter of most APIs was declared as - `'true' | 'false' | 'wait_for'`, which was clunky. Now is - `'wait_for' | boolean`. - -[discrete] -===== Generate response type as boolean if the request is HEAD only https://github.com/elastic/elasticsearch-js/pull/1275[#1275] - -All HEAD request will have the body casted to a boolean value, `true` in case of -a 200 response, `false` in case of a 404 response. The type definitions were not -reflecting this behavior. - -[source,ts] ----- -import { Client } from '@elastic/elasticsearch' -const client = new Client({ - node: 'http://localhost:9200' -}) - -const { body } = await client.exist({ index: 'my-index', id: 'my-id' }) -console.log(body) // either `true` or `false` ----- - -[discrete] -==== Internals - -[discrete] -===== Updated default http agent configuration https://github.com/elastic/elasticsearch-js/pull/1242[#1242] - -Added the scheduling: 'lifo' option to the default HTTP agent configuration to -avoid maximizing the open sockets against {es} and lowering the risk of -encountering socket timeouts. This feature is only available from Node v14.5+, -but it should be backported to v10 and v12 -(https://github.com/nodejs/node/pull/33278[nodejs/node#33278]). - -[discrete] -===== Improve child API https://github.com/elastic/elasticsearch-js/pull/1245[#1245] - -This pr introduce two changes which should not impact the surface API: - -* Refactored the `client.child` API to allocate fewer objects, this change - improves memory consumption over time and improves the child creation - performances by ~12%. -* The client no longer inherits from the EventEmitter class, but instead has an - internal event emitter and exposes only the API useful for the users, namely - `emit, `on`, `once`, and `off`. The type definitions have been updated - accordingly. - -[discrete] -=== 7.8.0 - -[discrete] -==== Features - -[discrete] -===== Support for Elasticsearch `v7.8`. - -You can find all the API changes https://www.elastic.co/guide/en/elasticsearch/reference/7.8/release-notes-7.8.0.html[here]. - -[discrete] -===== Added multi search helper https://github.com/elastic/elasticsearch-js/pull/1186[#1186] - -If you are sending search request at a high rate, this helper might be useful -for you. It will use the mutli search API under the hood to batch the requests -and improve the overall performances of your application. The `result` exposes a -`documents` property as well, which allows you to access directly the hits -sources. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') - -const client = new Client({ node: 'http://localhost:9200' }) -const m = client.helpers.msearch() - -// promise style API -m.search( - { index: 'stackoverflow' }, - { query: { match: { title: 'javascript' } } } - ) - .then(result => console.log(result.body)) // or result.documents - .catch(err => console.error(err)) - -// callback style API -m.search( - { index: 'stackoverflow' }, - { query: { match: { title: 'ruby' } } }, - (err, result) => { - if (err) console.error(err) - console.log(result.body)) // or result.documents - } -) ----- - -[discrete] -===== Added timeout support in bulk and msearch helpers https://github.com/elastic/elasticsearch-js/pull/1206[#1206] - -If there is a slow producer, the bulk helper might send data with a very large -period of time, and if the process crashes for any reason, the data would be -lost. This pr introduces a `flushInterval` option in the bulk helper to avoid -this issue. By default, the bulk helper will flush the data automatically every -30 seconds, unless the threshold has been reached before. - -[source,js] ----- -const b = client.helpers.bulk({ - flushInterval: 30000 -}) ----- - -The same problem might happen with the multi search helper, where the user is -not sending search requests fast enough. A `flushInterval` options has been -added as well, with a default value of 500 milliseconds. - -[source,js] ----- -const m = client.helpers.msearch({ - flushInterval: 500 -}) ----- - -[discrete] -==== Internals - -[discrete] -===== Use filter_path for improving the search helpers performances https://github.com/elastic/elasticsearch-js/pull/1199[#1199] - -From now on, all he search helpers will use the `filter_path` option -automatically when needed to retrieve only the hits source. This change will -result in less netwprk traffic and improved deserialization performances. - -[discrete] -===== Search helpers documents getter https://github.com/elastic/elasticsearch-js/pull/1186[#1186] - -Before this, the `documents` key that you can access in any search helper was -computed as soon as we got the search result from Elasticsearch. With this -change the `documents` key is now a getter, which makes this process lazy, -resulting in better performances and lower memory impact. - -[discrete] -=== 7.7.1 - -[discrete] -==== Fixes - -[discrete] -===== Disable client Helpers in Node.js < 10 - https://github.com/elastic/elasticsearch-js/pull/1194[#1194] - -The client helpers can't be used in Node.js < 10 because it needs a custom flag -to be able to use them. Given that not every provider allows the user to specify -custom Node.js flags, the Helpers has been disabled completely in Node.js < 10. - -[discrete] -===== Force lowercase in all headers - https://github.com/elastic/elasticsearch-js/pull/1187[#1187] - -Now all the user-provided headers names will be lowercased by default, so there -will be no conflicts in case of the same header with different casing. - -[discrete] -=== 7.7.0 - -[discrete] -==== Features - -[discrete] -===== Support for Elasticsearch `v7.7`. - -You can find all the API changes -https://www.elastic.co/guide/en/elasticsearch/reference/7.7/release-notes-7.7.0.html[here]. - -[discrete] -===== Introduced client helpers - https://github.com/elastic/elasticsearch-js/pull/1107[#1107] - -From now on, the client comes with an handy collection of helpers to give you a -more comfortable experience with some APIs. - -CAUTION: The client helpers are experimental, and the API may change in the next -minor releases. - -The following helpers has been introduced: - -- `client.helpers.bulk` -- `client.helpers.search` -- `client.helpers.scrollSearch` -- `client.helpers.scrollDocuments` - -[discrete] -===== The `ConnectionPool.getConnection` now always returns a `Connection` - https://github.com/elastic/elasticsearch-js/pull/1127[#1127] - -What does this mean? It means that you will see less `NoLivingConnectionError`, -which now can only be caused if you set a selector/filter too strict. For -improving the debugging experience, the `NoLivingConnectionsError` error message -has been updated. - -[discrete] -===== Abortable promises - https://github.com/elastic/elasticsearch-js/pull/1141[#1141] - -From now on, it will be possible to abort a request generated with the -promise-styl API. If you abort a request generated from a promise, the promise -will be rejected with a `RequestAbortedError`. - - -[source,js] ----- -const promise = client.search({ - body: { - query: { match_all: {} } - } -}) - -promise - .then(console.log) - .catch(console.log) - -promise.abort() ----- - -[discrete] -===== Major refactor of the Type Definitions - https://github.com/elastic/elasticsearch-js/pull/1119[#1119] https://github.com/elastic/elasticsearch-js/issues/1130[#1130] https://github.com/elastic/elasticsearch-js/pull/1132[#1132] - -Now every API makes better use of the generics and overloading, so you can (or -not, by default request/response bodies are `Record`) define the -request/response bodies in the generics. - -[source,ts] ----- -// request and response bodies are generics -client.search(...) -// response body is `SearchResponse` and request body is generic -client.search(...) -// request body is `SearchBody` and response body is `SearchResponse` -client.search(...) ----- - -This *should* not be a breaking change, as every generics defaults to `any`. It -might happen to some users that the code breaks, but our test didn't detect any -of it, probably because they were not robust enough. However, given the gigantic -improvement in the developer experience, we have decided to release this change -in the 7.x line. - -[discrete] -==== Fixes - -[discrete] -===== The `ConnectionPool.update` method now cleans the `dead` list - https://github.com/elastic/elasticsearch-js/issues/1122[#1122] https://github.com/elastic/elasticsearch-js/pull/1127[#1127] - -It can happen in a situation where we are updating the connections list and -running sniff, leaving the `dead` list in a dirty state. Now the -`ConnectionPool.update` cleans up the `dead` list every time, which makes way -more sense given that all the new connections are alive. - -[discrete] -===== `ConnectionPoolmarkDead` should ignore connections that no longer exists - https://github.com/elastic/elasticsearch-js/pull/1159[#1159] - -It might happen that markDead is called just after a pool update, and in such -case, the client was adding the dead list a node that no longer exists, causing -unhandled exceptions later. - -[discrete] -===== Do not retry a request if the body is a stream - https://github.com/elastic/elasticsearch-js/pull/1143[#1143] - -The client should not retry if it's sending a stream body, because it should -store in memory a copy of the stream to be able to send it again, but since it -doesn't know in advance the size of the stream, it risks to take too much -memory. Furthermore, copying everytime the stream is very an expensive -operation. - -[discrete] -===== Return an error if the request has been aborted - https://github.com/elastic/elasticsearch-js/pull/1141[#1141] - -Until now, aborting a request was blocking the HTTP request, but never calling -the callback or resolving the promise to notify the user. This is a bug because -it could lead to dangerous memory leaks. From now on if the user calls the -`request.abort()` method, the callback style API will be called with a -`RequestAbortedError`, the promise will be rejected with `RequestAbortedError` -as well. - -[discrete] -=== 7.6.1 - -**Fixes:** - -- Secure json parsing - - https://github.com/elastic/elasticsearch-js/pull/1110[#1110] -- ApiKey should take precedence over basic auth - - https://github.com/elastic/elasticsearch-js/pull/1115[#1115] - -**Documentation:** - -- Fix typo in api reference - - https://github.com/elastic/elasticsearch-js/pull/1109[#1109] - -[discrete] -=== 7.6.0 - -Support for Elasticsearch `v7.6`. - -[discrete] -=== 7.5.1 - -**Fixes:** - -- Skip compression in case of empty string body - - https://github.com/elastic/elasticsearch-js/pull/1080[#1080] -- Fix typo in NoLivingConnectionsError - - https://github.com/elastic/elasticsearch-js/pull/1045[#1045] -- Change TransportRequestOptions.ignore to number[] - - https://github.com/elastic/elasticsearch-js/pull/1053[#1053] -- ClientOptions["cloud"] should have optional auth fields - - https://github.com/elastic/elasticsearch-js/pull/1032[#1032] - -**Documentation:** - -- Docs: Return super in example Transport subclass - - https://github.com/elastic/elasticsearch-js/pull/980[#980] -- Add examples to reference - - https://github.com/elastic/elasticsearch-js/pull/1076[#1076] -- Added new examples - - https://github.com/elastic/elasticsearch-js/pull/1031[#1031] - -[discrete] -=== 7.5.0 - -Support for Elasticsearch `v7.5`. - -**Features** - -- X-Opaque-Id support https://github.com/elastic/elasticsearch-js/pull/997[#997] - -[discrete] -=== 7.4.0 - -Support for Elasticsearch `v7.4`. - -**Fixes:** - -- Fix issue; node roles are defaulting to true when undefined is breaking usage - of nodeFilter option - - https://github.com/elastic/elasticsearch-js/pull/967[#967] - -**Documentation:** - -- Updated API reference doc - - https://github.com/elastic/elasticsearch-js/pull/945[#945], - https://github.com/elastic/elasticsearch-js/pull/969[#969] -- Fix inaccurate description sniffEndpoint - - https://github.com/elastic/elasticsearch-js/pull/959[#959] - -**Internals:** - -- Update code generation - https://github.com/elastic/elasticsearch-js/pull/969[#969] - -[discrete] -=== 7.3.0 - -Support for Elasticsearch `v7.3`. - -**Features:** - -- Added `auth` option - - https://github.com/elastic/elasticsearch-js/pull/908[#908] -- Added support for `ApiKey` authentication - - https://github.com/elastic/elasticsearch-js/pull/908[#908] - -**Fixes:** - -- fix(Typings): sniffInterval can also be boolean - - https://github.com/elastic/elasticsearch-js/pull/914[#914] - -**Internals:** - -- Refactored connection pool - - https://github.com/elastic/elasticsearch-js/pull/913[#913] - -**Documentation:** - -- Better reference code examples - - https://github.com/elastic/elasticsearch-js/pull/920[#920] -- Improve README - - https://github.com/elastic/elasticsearch-js/pull/909[#909] - -[discrete] -=== 7.2.0 - -Support for Elasticsearch `v7.2` - -**Fixes:** - -- Remove auth data from inspect and toJSON in connection class - - https://github.com/elastic/elasticsearch-js/pull/887[#887] - -[discrete] -=== 7.1.0 - -Support for Elasticsearch `v7.1` - -**Fixes:** - -- Support for non-friendly chars in url username and password - - https://github.com/elastic/elasticsearch-js/pull/858[#858] -- Patch deprecated parameters - - https://github.com/elastic/elasticsearch-js/pull/851[#851] - -[discrete] -=== 7.0.1 - -**Fixes:** - -- Fix TypeScript export *(issue - https://github.com/elastic/elasticsearch-js/pull/841[#841])* - - https://github.com/elastic/elasticsearch-js/pull/842[#842] -- Fix http and https port handling *(issue - https://github.com/elastic/elasticsearch-js/pull/843[#843])* - - https://github.com/elastic/elasticsearch-js/pull/845[#845] -- Fix TypeScript definiton *(issue - https://github.com/elastic/elasticsearch-js/pull/803[#803])* - - https://github.com/elastic/elasticsearch-js/pull/846[#846] -- Added toJSON method to Connection class *(issue - https://github.com/elastic/elasticsearch-js/pull/848[#848])* - - https://github.com/elastic/elasticsearch-js/pull/849[#849] - -[discrete] -=== 7.0.0 - -Support for Elasticsearch `v7.0` - -- Stable release. diff --git a/docs/child.asciidoc b/docs/child.asciidoc deleted file mode 100644 index 3d8e40a96..000000000 --- a/docs/child.asciidoc +++ /dev/null @@ -1,33 +0,0 @@ -[[child]] -=== Creating a child client - -There are some use cases where you may need multiple instances of the client. -You can easily do that by calling `new Client()` as many times as you need, but -you will lose all the benefits of using one single client, such as the long -living connections and the connection pool handling. To avoid this problem the -client offers a `child` API, which returns a new client instance that shares the -connection pool with the parent client. - -NOTE: The event emitter is shared between the parent and the child(ren). If you -extend the parent client, the child client will have the same extensions, while -if the child client adds an extension, the parent client will not be extended. - -You can pass to the `child` every client option you would pass to a normal -client, but the connection pool specific options (`ssl`, `agent`, `pingTimeout`, -`Connection`, and `resurrectStrategy`). - -CAUTION: If you call `close` in any of the parent/child clients, every client -will be closed. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ node: 'http://localhost:9200' }) -const child = client.child({ - headers: { 'x-foo': 'bar' }, - requestTimeout: 1000 -}) - -client.info(console.log) -child.info(console.log) ----- diff --git a/docs/configuration.asciidoc b/docs/configuration.asciidoc deleted file mode 100644 index 2cd2114a8..000000000 --- a/docs/configuration.asciidoc +++ /dev/null @@ -1,12 +0,0 @@ -[[client-configuration]] -== Configuration - - -The client is designed to be easily configured for your needs. In the following -section, you can see the possible options that you can use to configure it. - -* <> -* <> -* <> -* <> -* <> diff --git a/docs/connecting.asciidoc b/docs/connecting.asciidoc deleted file mode 100644 index 30e1649f0..000000000 --- a/docs/connecting.asciidoc +++ /dev/null @@ -1,532 +0,0 @@ -[[client-connecting]] -== Connecting - -This page contains the information you need to connect and use the Client with -{es}. - -**On this page** - -* <> -* <> -* <> -* <> -* <> - -[discrete] -[[authentication]] -=== Authentication - -This document contains code snippets to show you how to connect to various {es} -providers. - - -[discrete] -[[auth-ec]] -==== Elastic Cloud - -If you are using https://www.elastic.co/cloud[Elastic Cloud], the client offers -an easy way to connect to it via the `cloud` option. You must pass the Cloud ID -that you can find in the cloud console, then your username and password inside -the `auth` option. - -NOTE: When connecting to Elastic Cloud, the client will automatically enable -both request and response compression by default, since it yields significant -throughput improvements. Moreover, the client will also set the ssl option -`secureProtocol` to `TLSv1_2_method` unless specified otherwise. You can still -override this option by configuring them. - -IMPORTANT: Do not enable sniffing when using Elastic Cloud, since the nodes are -behind a load balancer, Elastic Cloud will take care of everything for you. -Take a look https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how[here] -to know more. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ - cloud: { - id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==', - }, - auth: { - username: 'elastic', - password: 'changeme' - } -}) ----- - - -[discrete] -[[auth-apikey]] -==== ApiKey authentication - -You can use the -https://www.elastic.co/guide/en/elasticsearch/reference/7.x/security-api-create-api-key.html[ApiKey] -authentication by passing the `apiKey` parameter via the `auth` option. The -`apiKey` parameter can be either a base64 encoded string or an object with the -values that you can obtain from the -https://www.elastic.co/guide/en/elasticsearch/reference/7.x/security-api-create-api-key.html[create api key endpoint]. - -NOTE: If you provide both basic authentication credentials and the ApiKey -configuration, the ApiKey takes precedence. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ - node: 'https://localhost:9200', - auth: { - apiKey: 'base64EncodedKey' - } -}) ----- - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ - node: 'https://localhost:9200', - auth: { - apiKey: { - id: 'foo', - api_key: 'bar' - } - } -}) ----- - -[discrete] -[[auth-bearer]] -==== Bearer authentication - -You can provide your credentials by passing the `bearer` token -parameter via the `auth` option. -Useful for https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-service-token.html[service account tokens]. -Be aware that it does not handle automatic token refresh. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ - node: 'https://localhost:9200', - auth: { - bearer: 'token' - } -}) ----- - - -[discrete] -[[auth-basic]] -==== Basic authentication - -You can provide your credentials by passing the `username` and `password` -parameters via the `auth` option. - -NOTE: If you provide both basic authentication credentials and the Api Key -configuration, the Api Key will take precedence. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ - node: 'https://localhost:9200', - auth: { - username: 'elastic', - password: 'changeme' - } -}) ----- - - -Otherwise, you can provide your credentials in the node(s) URL. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ - node: 'https://username:password@localhost:9200' -}) ----- - - -[discrete] -[[auth-ssl]] -==== SSL configuration - -Without any additional configuration you can specify `https://` node urls, and -the certificates used to sign these requests will be verified. To turn off -certificate verification, you must specify an `ssl` object in the top level -config and set `rejectUnauthorized: false`. The default `ssl` values are the -same that Node.js's -https://nodejs.org/api/tls.html#tls_tls_connect_options_callback[`tls.connect()`] -uses. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ - node: 'https://localhost:9200', - auth: { - username: 'elastic', - password: 'changeme' - }, - ssl: { - ca: fs.readFileSync('./cacert.pem'), - rejectUnauthorized: false - } -}) ----- - -[discrete] -[[client-usage]] -=== Usage - -Using the client is straightforward, it supports all the public APIs of {es}, -and every method exposes the same signature. - - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ node: 'http://localhost:9200' }) - -// promise API -const result = await client.search({ - index: 'my-index', - body: { - query: { - match: { hello: 'world' } - } - } -}) - -// callback API -client.search({ - index: 'my-index', - body: { - query: { - match: { hello: 'world' } - } - } -}, (err, result) => { - if (err) console.log(err) -}) ----- - -The returned value of every API call is designed as follows: - -[source,ts] ----- -{ - body: object | boolean - statusCode: number - headers: object - warnings: [string], - meta: object -} ----- - -NOTE: The body is a boolean value when you use `HEAD` APIs. - -The above value is returned even if there is an error during the execution of -the request, this means that you can safely use the -https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment[destructuring assignment]. - -The `meta` key contains all the information about the request, such as attempt, -options, and the connection that has been used. - -[source,js] ----- -// promise API -const { body } = await client.search({ - index: 'my-index', - body: { - query: { - match: { hello: 'world' } - } - } -}) - -// callback API -client.search({ - index: 'my-index', - body: { - query: { - match: { hello: 'world' } - } - } -}, (err, { body }) => { - if (err) console.log(err) -}) ----- - - -[discrete] -==== Aborting a request - -If needed, you can abort a running request by calling the `request.abort()` -method returned by the API. - -CAUTION: If you abort a request, the request will fail with a -`RequestAbortedError`. - - -[source,js] ----- -const request = client.search({ - index: 'my-index', - body: { - query: { - match: { hello: 'world' } - } - } -}, { - ignore: [404], - maxRetries: 3 -}, (err, result) => { - if (err) { - console.log(err) // RequestAbortedError - } else { - console.log(result) - } -}) - -request.abort() ----- - -The same behavior is valid for the promise style API as well. - -[source,js] ----- -const request = client.search({ - index: 'my-index', - body: { - query: { - match: { hello: 'world' } - } - } -}, { - ignore: [404], - maxRetries: 3 -}) - -request - .then(result => console.log(result)) - .catch(err => console.log(err)) // RequestAbortedError - -request.abort() ----- - - -[discrete] -==== Request specific options - -If needed you can pass request specific options in a second object: - -[source,js] ----- -// promise API -const result = await client.search({ - index: 'my-index', - body: { - query: { - match: { hello: 'world' } - } - } -}, { - ignore: [404], - maxRetries: 3 -}) - -// callback API -client.search({ - index: 'my-index', - body: { - query: { - match: { hello: 'world' } - } - } -}, { - ignore: [404], - maxRetries: 3 -}, (err, { body }) => { - if (err) console.log(err) -}) ----- - - -The supported request specific options are: -[cols=2*] -|=== -|`ignore` -|`[number]` -  HTTP status codes which should not be considered errors for this request. + -_Default:_ `null` - -|`requestTimeout` -|`number` - Max request timeout for the request in milliseconds, it overrides the client default. + -_Default:_ `30000` - -|`maxRetries` -|`number` - Max number of retries for the request, it overrides the client default. + -_Default:_ `3` - -|`compression` -|`string, boolean` - Enables body compression for the request. + -_Options:_ `false`, `'gzip'` + -_Default:_ `false` - -|`asStream` -|`boolean` - Instead of getting the parsed body back, you get the raw Node.js stream of data. + -_Default:_ `false` - -|`headers` -|`object` - Custom headers for the request. + -_Default:_ `null` - -|`querystring` -|`object` - Custom querystring for the request. + -_Default:_ `null` - -|`id` -|`any` - Custom request id. _(overrides the top level request id generator)_ + -_Default:_ `null` - -|`context` -|`any` - Custom object per request. _(you can use it to pass data to the clients events)_ + -_Default:_ `null` -|=== - - -[discrete] -[[client-connect-proxy]] -=== Connecting through a proxy - -~Added~ ~in~ ~`v7.10.0`~ - -If you need to pass through an http(s) proxy for connecting to {es}, the client -offers out of the box a handy configuration for helping you with it. Under the -hood, it uses the https://github.com/delvedor/hpagent[`hpagent`] module. - -[source,js] ----- -const client = new Client({ - node: 'http://localhost:9200', - proxy: 'http://localhost:8080' -}) ----- - -Basic authentication is supported as well: - -[source,js] ----- -const client = new Client({ - node: 'http://localhost:9200', - proxy: 'http:user:pwd@//localhost:8080' -}) ----- - -If you are connecting through a not http(s) proxy, such as a `socks5` or `pac`, -you can use the `agent` option to configure it. - -[source,js] ----- -const SocksProxyAgent = require('socks-proxy-agent') -const client = new Client({ - node: 'http://localhost:9200', - agent () { - return new SocksProxyAgent('socks://127.0.0.1:1080') - } -}) ----- - - -[discrete] -[[client-error-handling]] -=== Error handling - -The client exposes a variety of error objects that you can use to enhance your -error handling. You can find all the error objects inside the `errors` key in -the client. - -[source,js] ----- -const { errors } = require('@elastic/elasticsearch') -console.log(errors) ----- - - -You can find the errors exported by the client in the table below. - -[cols=3*] -|=== -|*Error* -|*Description* -|*Properties* - -|`ElasticsearchClientError` -|Every error inherits from this class, it is the basic error generated by the client. -a|* `name` - `string` -* `message` - `string` - -|`TimeoutError` -|Generated when a request exceeds the `requestTimeout` option. -a|* `name` - `string` -* `message` - `string` -* `meta` - `object`, contains all the information about the request - -|`ConnectionError` -|Generated when an error occurs during the request, it can be a connection error or a malformed stream of data. -a|* `name` - `string` -* `message` - `string` -* `meta` - `object`, contains all the information about the request - -|`RequestAbortedError` -|Generated if the user calls the `request.abort()` method. -a|* `name` - `string` -* `message` - `string` -* `meta` - `object`, contains all the information about the request - -|`NoLivingConnectionsError` -|Given the configuration, the ConnectionPool was not able to find a usable Connection for this request. -a|* `name` - `string` -* `message` - `string` -* `meta` - `object`, contains all the information about the request - -|`SerializationError` -|Generated if the serialization fails. -a|* `name` - `string` -* `message` - `string` -* `data` - `object`, the object to serialize - -|`DeserializationError` -|Generated if the deserialization fails. -a|* `name` - `string` -* `message` - `string` -* `data` - `string`, the string to deserialize - -|`ConfigurationError` -|Generated if there is a malformed configuration or parameter. -a|* `name` - `string` -* `message` - `string` - -|`ResponseError` -|Generated when in case of a `4xx` or `5xx` response. -a|* `name` - `string` -* `message` - `string` -* `meta` - `object`, contains all the information about the request -* `body` - `object`, the response body -* `statusCode` - `object`, the response headers -* `headers` - `object`, the response status code -|=== - -[discrete] -[[compatible-check]] -=== Automatic compatible check - -Client can perform a compatible check before the first call. -This pre-flight compatible check allows the client to establish the version of Elasticsearch -that it is communicating with. The compatible check requires one additional HTTP request to -be sent to the server as part of the request pipeline before the main API call is sent. -In most cases, this will succeed during the very first API call that the client sends. -Once the compatible check completes, no further compatible check HTTP requests are sent for -subsequent API calls. diff --git a/docs/extend.asciidoc b/docs/extend.asciidoc deleted file mode 100644 index 069cacd86..000000000 --- a/docs/extend.asciidoc +++ /dev/null @@ -1,72 +0,0 @@ -[[extend]] -=== Extend the client - -Sometimes you need to reuse the same logic, or you want to build a custom API to -allow you simplify your code. The easiest way to achieve that is by extending -the client. - -NOTE: If you want to override existing methods, you should specify the -`{ force: true }` option. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ node: 'http://localhost:9200' }) - -client.extend('supersearch', ({ makeRequest, ConfigurationError }) => { - return function supersearch (params, options) { - const { - body, - index, - method, - ...querystring - } = params - - // params validation - if (body == null) { - throw new ConfigurationError('Missing required parameter: body') - } - - // build request object - const request = { - method: method || 'POST', - path: `/${encodeURIComponent(index)}/_search_`, - body, - querystring - } - - // build request options object - const requestOptions = { - ignore: options.ignore || null, - requestTimeout: options.requestTimeout || null, - maxRetries: options.maxRetries || null, - asStream: options.asStream || false, - headers: options.headers || null - } - - return makeRequest(request, requestOptions) - } -}) - -client.extend('utility.index', ({ makeRequest }) => { - return function _index (params, options) { - // your code - } -}) - -client.extend('utility.delete', ({ makeRequest }) => { - return function _delete (params, options) { - // your code - } -}) - -client.extend('indices.delete', { force: true }, ({ makeRequest }) => { - return function _delete (params, options) { - // your code - } -}) - -client.supersearch(...) -client.utility.index(...) -client.utility.delete(...) ----- \ No newline at end of file diff --git a/docs/helpers.asciidoc b/docs/helpers.asciidoc deleted file mode 100644 index 71dd9de15..000000000 --- a/docs/helpers.asciidoc +++ /dev/null @@ -1,579 +0,0 @@ -[[client-helpers]] -== Client helpers - -The client comes with an handy collection of helpers to give you a more -comfortable experience with some APIs. - -CAUTION: The client helpers are experimental, and the API may change in the next -minor releases. The helpers will not work in any Node.js version lower than 10. - - -[discrete] -[[bulk-helper]] -=== Bulk helper - -~Added~ ~in~ ~`v7.7.0`~ - -Running bulk requests can be complex due to the shape of the API, this helper -aims to provide a nicer developer experience around the Bulk API. - - -[discrete] -==== Usage - -[source,js] ----- -const { createReadStream } = require('fs') -const split = require('split2') -const { Client } = require('@elastic/elasticsearch') - -const client = new Client({ node: 'http://localhost:9200' }) -const result = await client.helpers.bulk({ - datasource: createReadStream('./dataset.ndjson').pipe(split()), - onDocument (doc) { - return { - index: { _index: 'my-index' } - } - } -}) - -console.log(result) -// { -// total: number, -// failed: number, -// retry: number, -// successful: number, -// time: number, -// bytes: number, -// aborted: boolean -// } ----- - -To create a new instance of the Bulk helper, access it as shown in the example -above, the configuration options are: -[cols=2*] -|=== -|`datasource` -a|An array, async generator or a readable stream with the data you need to index/create/update/delete. -It can be an array of strings or objects, but also a stream of json strings or JavaScript objects. + -If it is a stream, we recommend to use the https://www.npmjs.com/package/split2[`split2`] package, that splits the stream on new lines delimiters. + -This parameter is mandatory. -[source,js] ----- -const { createReadStream } = require('fs') -const split = require('split2') -const b = client.helpers.bulk({ - // if you just use split(), the data will be used as array of strings - datasource: createReadStream('./dataset.ndjson').pipe(split()) - // if you need to manipulate the data, you can pass JSON.parse to split - datasource: createReadStream('./dataset.ndjson').pipe(split(JSON.parse)) -}) ----- - -|`onDocument` -a|A function that is called for each document of the datasource. Inside this function you can manipulate the document and you must return the operation you want to execute with the document. Look at the link:{ref}/docs-bulk.html[Bulk API documentation] to see the supported operations. + -This parameter is mandatory. -[source,js] ----- -const b = client.helpers.bulk({ - onDocument (doc) { - return { - index: { _index: 'my-index' } - } - } -}) ----- - -|`onDrop` -a|A function that is called for everytime a document can't be indexed and it has reached the maximum amount of retries. -[source,js] ----- -const b = client.helpers.bulk({ - onDrop (doc) { - console.log(doc) - } -}) ----- - -|`flushBytes` -a|The size of the bulk body in bytes to reach before to send it. Default of 5MB. + -_Default:_ `5000000` -[source,js] ----- -const b = client.helpers.bulk({ - flushBytes: 1000000 -}) ----- - -|`flushInterval` -a|How much time (in milliseconds) the helper waits before flushing the body from the last document read. + -_Default:_ `30000` -[source,js] ----- -const b = client.helpers.bulk({ - flushInterval: 30000 -}) ----- - -|`concurrency` -a|How many request is executed at the same time. + -_Default:_ `5` -[source,js] ----- -const b = client.helpers.bulk({ - concurrency: 10 -}) ----- - -|`retries` -a|How many times a document is retried before to call the `onDrop` callback. + -_Default:_ Client max retries. -[source,js] ----- -const b = client.helpers.bulk({ - retries: 3 -}) ----- - -|`wait` -a|How much time to wait before retries in milliseconds. + -_Default:_ 5000. -[source,js] ----- -const b = client.helpers.bulk({ - wait: 3000 -}) ----- - -|`refreshOnCompletion` -a|If `true`, at the end of the bulk operation it runs a refresh on all indices or on the specified indices. + -_Default:_ false. -[source,js] ----- -const b = client.helpers.bulk({ - refreshOnCompletion: true - // or - refreshOnCompletion: 'index-name' -}) ----- - -|=== - - -[discrete] -==== Supported operations - - -[discrete] -===== Index - -[source,js] ----- -client.helpers.bulk({ - datasource: myDatasource, - onDocument (doc) { - return { - index: { _index: 'my-index' } - } - } -}) ----- - - -[discrete] -===== Create - -[source,js] ----- -client.helpers.bulk({ - datasource: myDatasource, - onDocument (doc) { - return { - create: { _index: 'my-index', _id: doc.id } - } - } -}) ----- - - -[discrete] -===== Update - -[source,js] ----- -client.helpers.bulk({ - datasource: myDatasource, - onDocument (doc) { - // Note that the update operation requires you to return - // an array, where the first element is the action, while - // the second are the document option - return [ - { update: { _index: 'my-index', _id: doc.id } }, - { doc_as_upsert: true } - ] - } -}) ----- - - -[discrete] -===== Delete - -[source,js] ----- -client.helpers.bulk({ - datasource: myDatasource, - onDocument (doc) { - return { - delete: { _index: 'my-index', _id: doc.id } - } - } -}) ----- - - -[discrete] -==== Abort a bulk operation - -If needed, you can abort a bulk operation at any time. The bulk helper returns a -https://promisesaplus.com/[thenable], which has an `abort` method. - -NOTE: The abort method stops the execution of the bulk operation, but if you -are using a concurrency higher than one, the operations that are already running -will not be stopped. - -[source,js] ----- -const { createReadStream } = require('fs') -const split = require('split2') -const { Client } = require('@elastic/elasticsearch') - -const client = new Client({ node: 'http://localhost:9200' }) -const b = client.helpers.bulk({ - datasource: createReadStream('./dataset.ndjson').pipe(split()), - onDocument (doc) { - return { - index: { _index: 'my-index' } - } - }, - onDrop (doc) { - b.abort() - } -}) - -console.log(await b) ----- - - -[discrete] -==== Passing custom options to the Bulk API - -You can pass any option supported by the link: -{ref}/docs-bulk.html#docs-bulk-api-query-params[Bulk API] to the helper, and the -helper uses those options in conjunction with the Bulk API call. - -[source,js] ----- -const result = await client.helpers.bulk({ - datasource: [...] - onDocument (doc) { - return { - index: { _index: 'my-index' } - } - }, - pipeline: 'my-pipeline' -}) ----- - - -[discrete] -==== Usage with an async generator - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') - -async function * generator () { - const dataset = [ - { user: 'jon', age: 23 }, - { user: 'arya', age: 18 }, - { user: 'tyrion', age: 39 } - ] - for (const doc of dataset) { - yield doc - } -} - -const client = new Client({ node: 'http://localhost:9200' }) -const result = await client.helpers.bulk({ - datasource: generator(), - onDocument (doc) { - return { - index: { _index: 'my-index' } - } - } -}) - -console.log(result) ----- - - -[discrete] -[[multi-search-helper]] -=== Multi search helper - -~Added~ ~in~ ~`v7.8.0`~ - -If you send search request at a high rate, this helper might be useful -for you. It uses the multi search API under the hood to batch the requests -and improve the overall performances of your application. The `result` exposes a -`documents` property as well, which allows you to access directly the hits -sources. - - -[discrete] -==== Usage - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') - -const client = new Client({ node: 'http://localhost:9200' }) -const m = client.helpers.msearch() - -// promise style API -m.search( - { index: 'stackoverflow' }, - { query: { match: { title: 'javascript' } } } - ) - .then(result => console.log(result.body)) // or result.documents - .catch(err => console.error(err)) - -// callback style API -m.search( - { index: 'stackoverflow' }, - { query: { match: { title: 'ruby' } } }, - (err, result) => { - if (err) console.error(err) - console.log(result.body)) // or result.documents - } -) ----- - -To create a new instance of the multi search (msearch) helper, you should access -it as shown in the example above, the configuration options are: -[cols=2*] -|=== -|`operations` -a|How many search operations should be sent in a single msearch request. + -_Default:_ `5` -[source,js] ----- -const m = client.helpers.msearch({ - operations: 10 -}) ----- - -|`flushInterval` -a|How much time (in milliseconds) the helper waits before flushing the operations from the last operation read. + -_Default:_ `500` -[source,js] ----- -const m = client.helpers.msearch({ - flushInterval: 500 -}) ----- - -|`concurrency` -a|How many request is executed at the same time. + -_Default:_ `5` -[source,js] ----- -const m = client.helpers.msearch({ - concurrency: 10 -}) ----- - -|`retries` -a|How many times an operation is retried before to resolve the request. An operation is retried only in case of a 429 error. + -_Default:_ Client max retries. -[source,js] ----- -const m = client.helpers.msearch({ - retries: 3 -}) ----- - -|`wait` -a|How much time to wait before retries in milliseconds. + -_Default:_ 5000. -[source,js] ----- -const m = client.helpers.msearch({ - wait: 3000 -}) ----- - -|=== - - -[discrete] -==== Stopping the msearch helper - -If needed, you can stop an msearch processor at any time. The msearch helper -returns a https://promisesaplus.com/[thenable], which has an `stop` method. - -If you are creating multiple msearch helpers instances and using them for a -limitied period of time, remember to always use the `stop` method once you have -finished using them, otherwise your application will start leaking memory. - -The `stop` method accepts an optional error, that will be dispatched every -subsequent search request. - -NOTE: The stop method stops the execution of the msearch processor, but if -you are using a concurrency higher than one, the operations that are already -running will not be stopped. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') - -const client = new Client({ node: 'http://localhost:9200' }) -const m = client.helpers.msearch() - -m.search( - { index: 'stackoverflow' }, - { query: { match: { title: 'javascript' } } } - ) - .then(result => console.log(result.body)) - .catch(err => console.error(err)) - -m.search( - { index: 'stackoverflow' }, - { query: { match: { title: 'ruby' } } } - ) - .then(result => console.log(result.body)) - .catch(err => console.error(err)) - -setImmediate(() => m.stop()) ----- - - -[discrete] -[[search-helper]] -=== Search helper - -~Added~ ~in~ ~`v7.7.0`~ - -A simple wrapper around the search API. Instead of returning the entire `result` -object it returns only the search documents source. For improving the -performances, this helper automatically adds `filter_path=hits.hits._source` to -the query string. - -[source,js] ----- -const documents = await client.helpers.search({ - index: 'stackoverflow', - body: { - query: { - match: { - title: 'javascript' - } - } - } -}) - -for (const doc of documents) { - console.log(doc) -} ----- - - -[discrete] -[[scroll-search-helper]] -=== Scroll search helper - -~Added~ ~in~ ~`v7.7.0`~ - -This helpers offers a simple and intuitive way to use the scroll search API. -Once called, it returns an -https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function[async iterator] -which can be used in conjuction with a for-await...of. It handles automatically -the `429` error and uses the `maxRetries` option of the client. - -[source,js] ----- -const scrollSearch = client.helpers.scrollSearch({ - index: 'stackoverflow', - body: { - query: { - match: { - title: 'javascript' - } - } - } -}) - -for await (const result of scrollSearch) { - console.log(result) -} ----- - - -[discrete] -==== Clear a scroll search - -If needed, you can clear a scroll search by calling `result.clear()`: - -[source,js] ----- -for await (const result of scrollSearch) { - if (condition) { - await result.clear() - } -} ----- - - -[discrete] -==== Quickly getting the documents - -If you only need the documents from the result of a scroll search, you can -access them via `result.documents`: - -[source,js] ----- -for await (const result of scrollSearch) { - console.log(result.documents) -} ----- - - -[discrete] -[[scroll-documents-helper]] -=== Scroll documents helper - -~Added~ ~in~ ~`v7.7.0`~ - -It works in the same way as the scroll search helper, but it returns only the -documents instead. Note, every loop cycle returns a single document, and you -can't use the `clear` method. For improving the performances, this helper -automatically adds `filter_path=hits.hits._source` to the query string. - -[source,js] ----- -const scrollSearch = client.helpers.scrollDocuments({ - index: 'stackoverflow', - body: { - query: { - match: { - title: 'javascript' - } - } - } -}) - -for await (const doc of scrollSearch) { - console.log(doc) -} ----- \ No newline at end of file diff --git a/docs/index.asciidoc b/docs/index.asciidoc deleted file mode 100644 index 065c99ecb..000000000 --- a/docs/index.asciidoc +++ /dev/null @@ -1,23 +0,0 @@ -= Elasticsearch Node.js client - -:branch: 7.x -include::{asciidoc-dir}/../../shared/attributes.asciidoc[] - -include::introduction.asciidoc[] -include::installation.asciidoc[] -include::connecting.asciidoc[] -include::configuration.asciidoc[] -include::basic-config.asciidoc[] -include::advanced-config.asciidoc[] -include::child.asciidoc[] -include::extend.asciidoc[] -include::testing.asciidoc[] -include::integrations.asciidoc[] -include::observability.asciidoc[] -include::transport.asciidoc[] -include::typescript.asciidoc[] -include::reference.asciidoc[] -include::examples/index.asciidoc[] -include::helpers.asciidoc[] -include::changelog.asciidoc[] -include::redirects.asciidoc[] diff --git a/docs/installation.asciidoc b/docs/installation.asciidoc deleted file mode 100644 index 83628a3d6..000000000 --- a/docs/installation.asciidoc +++ /dev/null @@ -1,94 +0,0 @@ -[[installation]] -== Installation - -This page guides you through the installation process of the client. - -To install the latest version of the client, run the following command: - -[source,sh] ----- -npm install @elastic/elasticsearch ----- - -To install a specific major version of the client, run the following command: - -[source,sh] ----- -npm install @elastic/elasticsearch@ ----- - -To learn more about the supported major versions, please refer to the -<>. - -[discrete] -[[nodejs-support]] -=== Node.js support - -NOTE: The minimum supported version of Node.js is `v10`. - -The client versioning follows the {stack} versioning, this means that -major, minor, and patch releases are done following a precise schedule that -often does not coincide with the https://nodejs.org/en/about/releases/[Node.js release] times. - -To avoid support insecure and unsupported versions of Node.js, the -client *will drop the support of EOL versions of Node.js between minor releases*. -Typically, as soon as a Node.js version goes into EOL, the client will continue -to support that version for at least another minor release. If you are using the client -with a version of Node.js that will be unsupported soon, you will see a warning -in your logs (the client will start logging the warning with two minors in advance). - -Unless you are *always* using a supported version of Node.js, -we recommend defining the client dependency in your -`package.json` with the `~` instead of `^`. In this way, you will lock the -dependency on the minor release and not the major. (for example, `~7.10.0` instead -of `^7.10.0`). - -[%header,cols=3*] -|=== -|Node.js Version -|Node.js EOL date -|End of support - -|`8.x` -|December 2019 -|`7.11` (early 2021) - -|`10.x` -|April 2021 -|`7.12` (mid 2021) -|=== - -[discrete] -[[js-compatibility-matrix]] -=== Compatibility matrix - -The library is compatible with all {es} versions since 5.x. We recommend you to -use the same major version of the client as the {es} instance that you are -using. - -[%header,cols=2*] -|=== -|{es} Version -|Client Version - -|`master` -|`master` - -|`7.x` -|`7.x` - -|`6.x` -|`6.x` - -|`5.x` -|`5.x` -|=== - - -[discrete] -==== Browser - -WARNING: There is no official support for the browser environment. It exposes -your {es} instance to everyone, which could lead to security issues. We -recommend you to write a lightweight proxy that uses this client instead, -you can see a proxy example https://github.com/elastic/elasticsearch-js/tree/master/docs/examples/proxy[here]. \ No newline at end of file diff --git a/docs/integrations.asciidoc b/docs/integrations.asciidoc deleted file mode 100644 index 84f854ab2..000000000 --- a/docs/integrations.asciidoc +++ /dev/null @@ -1,8 +0,0 @@ -[[integrations]] -== Integrations - -The Client offers the following integration options for you: - -* <> -* <> -* <> \ No newline at end of file diff --git a/docs/introduction.asciidoc b/docs/introduction.asciidoc deleted file mode 100644 index 89ce92d81..000000000 --- a/docs/introduction.asciidoc +++ /dev/null @@ -1,195 +0,0 @@ -[[introduction]] -== Introduction - -This is the official Node.js client for {es}. This page gives a quick overview -about the features of the client. - -Refer to <> for breaking changes coming from the old -client. - -[discrete] -=== Features - -* One-to-one mapping with REST API. -* Generalized, pluggable architecture. -* Configurable, automatic discovery of cluster nodes. -* Persistent, Keep-Alive connections. -* Load balancing across all available nodes. -* Child client support. -* TypeScript support out of the box. - - -[discrete] -=== Quick start - -First of all, require, then initialize the client: - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ node: 'http://localhost:9200' }) ----- - - -You can use both the callback API and the promise API, both behave the same way. - -[source,js] ----- -// promise API -const result = await client.search({ - index: 'my-index', - body: { - query: { - match: { hello: 'world' } - } - } -}) - -// callback API -client.search({ - index: 'my-index', - body: { - query: { - match: { hello: 'world' } - } - } -}, (err, result) => { - if (err) console.log(err) -}) ----- - - -The returned value of **every** API call is formed as follows: - -[source,ts] ----- -{ - body: object | boolean - statusCode: number - headers: object - warnings: [string] - meta: object -} ----- - - -Let's see a complete example! - -[source,js] ----- -'use strict' - -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ node: 'http://localhost:9200' }) - -async function run () { - // Let's start by indexing some data - await client.index({ - index: 'game-of-thrones', - // type: '_doc', // uncomment this line if you are using {es} ≤ 6 - body: { - character: 'Ned Stark', - quote: 'Winter is coming.' - } - }) - - await client.index({ - index: 'game-of-thrones', - // type: '_doc', // uncomment this line if you are using {es} ≤ 6 - body: { - character: 'Daenerys Targaryen', - quote: 'I am the blood of the dragon.' - } - }) - - await client.index({ - index: 'game-of-thrones', - // type: '_doc', // uncomment this line if you are using {es} ≤ 6 - body: { - character: 'Tyrion Lannister', - quote: 'A mind needs books like a sword needs a whetstone.' - } - }) - - // We need to force an index refresh at this point, otherwise we will not - // get any result in the consequent search - await client.indices.refresh({ index: 'game-of-thrones' }) - - // Let's search! - const { body } = await client.search({ - index: 'game-of-thrones', - // type: '_doc', // uncomment this line if you are using {es} ≤ 6 - body: { - query: { - match: { quote: 'winter' } - } - } - }) - - console.log(body.hits.hits) -} - -run().catch(console.log) ----- - -[discrete] -==== Install multiple versions - -If you are using multiple versions of {es}, you need to use multiple versions of -the client as well. In the past, installing multiple versions of the same -package was not possible, but with `npm v6.9`, you can do it via aliasing. - -To install different version of the client, run the following command: - -[source,sh] ----- -npm install @npm:@elastic/elasticsearch@ ----- - - -For example, if you need to install `7.x` and `6.x`, run the following commands: - -[source,sh] ----- -npm install es6@npm:@elastic/elasticsearch@6 -npm install es7@npm:@elastic/elasticsearch@7 ----- - - -Your `package.json` will look similar to the following example: - -[source,json] ----- -"dependencies": { - "es6": "npm:@elastic/elasticsearch@^6.7.0", - "es7": "npm:@elastic/elasticsearch@^7.0.0" -} ----- - - -Require the packages from your code by using the alias you have defined. - -[source,js] ----- -const { Client: Client6 } = require('es6') -const { Client: Client7 } = require('es7') - -const client6 = new Client6({ node: 'http://localhost:9200' }) -const client7 = new Client7({ node: 'http://localhost:9201' }) - -client6.info(console.log) -client7.info(console.log) ----- - - -Finally, if you want to install the client for the next version of {es} (the one -that lives in the {es} master branch), use the following command: - -[source,sh] ----- -npm install esmaster@github:elastic/elasticsearch-js ----- -WARNING: This command installs the master branch of the client which is not -considered stable. - -include::breaking-changes.asciidoc[] \ No newline at end of file diff --git a/docs/observability.asciidoc b/docs/observability.asciidoc deleted file mode 100644 index c20ed28f9..000000000 --- a/docs/observability.asciidoc +++ /dev/null @@ -1,428 +0,0 @@ -[[observability]] -=== Observability - -The client does not provide a default logger, but instead it offers an event -emitter interfaces to hook into internal events, such as `request` and -`response`. - -Correlating those events can be hard, especially if your applications have a -large codebase with many events happening at the same time. - -To help you with this, the client offers you a correlation id system and other -features. Let's see them in action. - - -[discrete] -==== Events - -The client is an event emitter, this means that you can listen for its event and -add additional logic to your code, without need to change the client internals -or your normal usage. You can find the events names by access the `events` key -of the client. - -[source,js] ----- -const { events } = require('@elastic/elasticsearch') -console.log(events) ----- - - -The event emitter functionality can be useful if you want to log every request, -response and error that is happening during the use of the client. - -[source,js] ----- -const logger = require('my-logger')() -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ node: 'http://localhost:9200' }) - -client.on('response', (err, result) => { - if (err) { - logger.error(err) - } else { - logger.info(result) - } -}) ----- - - -The client emits the following events: -[cols=2*] -|=== -|`serialization` -a|Emitted before starting serialization and compression. If you want to measure this phase duration, you should measure the time elapsed between this event and `request`. -[source,js] ----- -client.on('serialization', (err, result) => { - console.log(err, result) -}) ----- - -|`request` -a|Emitted before sending the actual request to {es} _(emitted multiple times in case of retries)_. -[source,js] ----- -client.on('request', (err, result) => { - console.log(err, result) -}) ----- - -|`deserialization` -a|Emitted before starting deserialization and decompression. If you want to measure this phase duration, you should measure the time elapsed between this event and `response`. _(This event might not be emitted in certain situations)_. -[source,js] ----- -client.on('deserialization', (err, result) => { - console.log(err, result) -}) ----- - -|`response` -a|Emitted once {es} response has been received and parsed. -[source,js] ----- -client.on('response', (err, result) => { - console.log(err, result) -}) ----- - -|`sniff` -a|Emitted when the client ends a sniffing request. -[source,js] ----- -client.on('sniff', (err, result) => { - console.log(err, result) -}) ----- - -|`resurrect` -a|Emitted if the client is able to resurrect a dead node. -[source,js] ----- -client.on('resurrect', (err, result) => { - console.log(err, result) -}) ----- - -|=== - -The values of `result` in `serialization`, `request`, `deserialization`, -`response` and `sniff` are: - -[source,ts] ----- -body: any; -statusCode: number | null; -headers: anyObject | null; -warnings: string[] | null; -meta: { - context: any; - name: string; - request: { - params: TransportRequestParams; - options: TransportRequestOptions; - id: any; - }; - connection: Connection; - attempts: number; - aborted: boolean; - sniff?: { - hosts: any[]; - reason: string; - }; -}; ----- - - -While the `result` value in `resurrect` is: - -[source,ts] ----- -strategy: string; -isAlive: boolean; -connection: Connection; -name: string; -request: { - id: any; -}; ----- - -[discrete] -===== Events order - -The event order is described in the following graph, in some edge cases, the -order is not guaranteed. -You can find in -https://github.com/elastic/elasticsearch-js/blob/master/test/acceptance/events-order.test.js[`test/acceptance/events-order.test.js`] -how the order changes based on the situation. - -[source] ----- -serialization - │ - │ (serialization and compression happens between those two events) - │ - └─▶ request - │ - │ (actual time spent over the wire) - │ - └─▶ deserialization - │ - │ (deserialization and decompression happens between those two events) - │ - └─▶ response ----- - - -[discrete] -==== Correlation id - -Correlating events can be hard, especially if there are many events at the same -time. The client offers you an automatic (and configurable) system to help you -handle this problem. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ node: 'http://localhost:9200' }) - -client.on('request', (err, result) => { - const { id } = result.meta.request - if (err) { - console.log({ error: err, reqId: id }) - } -}) - -client.on('response', (err, result) => { - const { id } = result.meta.request - if (err) { - console.log({ error: err, reqId: id }) - } -}) - -client.search({ - index: 'my-index', - body: { foo: 'bar' } -}, (err, result) => { - if (err) console.log(err) -}) ----- - - -By default the id is an incremental integer, but you can configure it with the -`generateRequestId` option: - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ - node: 'http://localhost:9200', - // it takes two parameters, the request parameters and options - generateRequestId: function (params, options) { - // your id generation logic - // must be syncronous - return 'id' - } -}) ----- - - -You can also specify a custom id per request: - -[source,js] ----- -client.search({ - index: 'my-index', - body: { foo: 'bar' } -}, { - id: 'custom-id' -}, (err, result) => { - if (err) console.log(err) -}) ----- - - -[discrete] -==== Context object - -Sometimes, you might need to make some custom data available in your events, you -can do that via the `context` option of a request: - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ node: 'http://localhost:9200' }) - -client.on('request', (err, result) => { - const { id } = result.meta.request - const { context } = result.meta - if (err) { - console.log({ error: err, reqId: id, context }) - } -}) - -client.on('response', (err, result) => { - const { id } = result.meta.request - const { winter } = result.meta.context - if (err) { - console.log({ error: err, reqId: id, winter }) - } -}) - -client.search({ - index: 'my-index', - body: { foo: 'bar' } -}, { - context: { winter: 'is coming' } -}, (err, result) => { - if (err) console.log(err) -}) ----- - -The context object can also be configured as a global option in the client -configuration. If you provide both, the two context objects will be shallow -merged, and the API level object will take precedence. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ - node: 'http://localhost:9200', - context: { winter: 'is coming' } -}) - -client.on('request', (err, result) => { - const { id } = result.meta.request - const { context } = result.meta - if (err) { - console.log({ error: err, reqId: id, context }) - } -}) - -client.on('response', (err, result) => { - const { id } = result.meta.request - const { winter } = result.meta.context - if (err) { - console.log({ error: err, reqId: id, winter }) - } -}) - -client.search({ - index: 'my-index', - body: { foo: 'bar' } -}, { - context: { winter: 'has come' } -}, (err, result) => { - if (err) console.log(err) -}) ----- - - -[discrete] -==== Client name - -If you are using multiple instances of the client or if you are using multiple -child clients _(which is the recommended way to have multiple instances of the -client)_, you might need to recognize which client you are using. The `name` -options help you in this regard. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ - node: 'http://localhost:9200', - name: 'parent-client' // default to 'elasticsearch-js' -}) - -const child = client.child({ - name: 'child-client' -}) - -console.log(client.name, child.name) - -client.on('request', (err, result) => { - const { id } = result.meta.request - const { name } = result.meta - if (err) { - console.log({ error: err, reqId: id, name }) - } -}) - -client.on('response', (err, result) => { - const { id } = result.meta.request - const { name } = result.meta - if (err) { - console.log({ error: err, reqId: id, name }) - } -}) - -client.search({ - index: 'my-index', - body: { foo: 'bar' } -}, (err, result) => { - if (err) console.log(err) -}) - -child.search({ - index: 'my-index', - body: { foo: 'bar' } -}, (err, result) => { - if (err) console.log(err) -}) ----- - - -[discrete] -==== X-Opaque-Id support - -To improve observability, the client offers an easy way to configure the -`X-Opaque-Id` header. If you set the `X-Opaque-Id` in a specific request, this -allows you to discover this identifier in the -https://www.elastic.co/guide/en/elasticsearch/reference/master/logging.html#deprecation-logging[deprecation logs], -helps you with https://www.elastic.co/guide/en/elasticsearch/reference/master/index-modules-slowlog.html#_identifying_search_slow_log_origin[identifying search slow log origin] -as well as https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html#_identifying_running_tasks[identifying running tasks]. - -The `X-Opaque-Id` should be configured in each request, for doing that you can -use the `opaqueId` option, as you can see in the following example. The -resulting header will be `{ 'X-Opaque-Id': 'my-search' }`. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ - node: 'http://localhost:9200' -}) - -client.search({ - index: 'my-index', - body: { foo: 'bar' } -}, { - opaqueId: 'my-search' -}, (err, result) => { - if (err) console.log(err) -}) ----- - - -Sometimes it may be useful to prefix all the `X-Opaque-Id` headers with a -specific string, in case you need to identify a specific client or server. For -doing this, the client offers a top-level configuration option: -`opaqueIdPrefix`. In the following example, the resulting header will be -`{ 'X-Opaque-Id': 'proxy-client::my-search' }`. - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ - node: 'http://localhost:9200', - opaqueIdPrefix: 'proxy-client::' -}) - -client.search({ - index: 'my-index', - body: { foo: 'bar' } -}, { - opaqueId: 'my-search' -}, (err, result) => { - if (err) console.log(err) -}) ----- diff --git a/docs/redirects.asciidoc b/docs/redirects.asciidoc deleted file mode 100644 index a7d0ec46d..000000000 --- a/docs/redirects.asciidoc +++ /dev/null @@ -1,9 +0,0 @@ -"appendix",role="exclude",id="redirects"] -= Deleted pages - -The following pages have moved or been deleted. - -[role="exclude",id="auth-reference"] -== Authentication - -This page has moved. See <>. diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc deleted file mode 100644 index 2b6ed7bb0..000000000 --- a/docs/reference.asciidoc +++ /dev/null @@ -1,11995 +0,0 @@ -[[api-reference]] - -//////// - - - -=========================================================================================================================== -|| || -|| || -|| || -|| ██████╗ ███████╗ █████╗ ██████╗ ███╗ ███╗███████╗ || -|| ██╔══██╗██╔════╝██╔══██╗██╔══██╗████╗ ████║██╔════╝ || -|| ██████╔╝█████╗ ███████║██║ ██║██╔████╔██║█████╗ || -|| ██╔══██╗██╔══╝ ██╔══██║██║ ██║██║╚██╔╝██║██╔══╝ || -|| ██║ ██║███████╗██║ ██║██████╔╝██║ ╚═╝ ██║███████╗ || -|| ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚══════╝ || -|| || -|| || -|| This file is autogenerated, DO NOT send pull requests that changes this file directly. || -|| You should update the script that does the generation, which can be found in '/scripts/utils/generateDocs.js'. || -|| || -|| You can run the script with the following command: || -|| node scripts/generate --branch || -|| or || -|| node scripts/generate --tag || -|| || -|| || -|| || -=========================================================================================================================== - - - -//////// - -== API Reference - -This document contains the entire list of the Elasticsearch API supported by the client, both OSS and commercial. The client is entirely licensed under Apache 2.0. - -Elasticsearch exposes an HTTP layer to communicate with, and the client is a library that will help you do this. Because of this reason, you will see HTTP related parameters, such as `body` or `headers`. - -Every API can accept two objects, the first contains all the parameters that will be sent to Elasticsearch, while the second includes the request specific parameters, such as timeouts, headers, and so on. -In the first object, every parameter but the body will be sent via querystring or url parameter, depending on the API, and every unrecognized parameter will be sent as querystring. - -[source,js] ----- -// promise API -const result = await client.search({ - index: 'my-index', - from: 20, - size: 10, - body: { foo: 'bar' } -}, { - ignore: [404], - maxRetries: 3 -}) - -// callback API -client.search({ - index: 'my-index', - from: 20, - size: 10, - body: { foo: 'bar' } -}, { - ignore: [404], - maxRetries: 3 -}, (err, result) => { - if (err) console.log(err) -}) ----- - -In this document, you will find the reference of every parameter accepted by the querystring or the url. If you also need to send the body, you can find the documentation of its format in the reference link that is present along with every endpoint. - - - -[discrete] -=== Common parameters -Parameters that are accepted by all API endpoints. - -link:{ref}/common-options.html[Documentation] -[cols=2*] -|=== -|`pretty` -|`boolean` - Pretty format the returned JSON response. - -|`human` -|`boolean` - Return human readable values for statistics. + - _Default:_ `true` - -|`error_trace` or `errorTrace` -|`boolean` - Include the stack trace of returned errors. - -|`source` -|`string` - The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - -|`filter_path` or `filterPath` -|`list` - A comma-separated list of filters used to reduce the response. - -|=== -[discrete] -=== asyncSearch.delete - -[source,ts] ----- -client.asyncSearch.delete({ - id: string -}) ----- -link:{ref}/async-search.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The async search ID - -|=== - -[discrete] -=== asyncSearch.get - -[source,ts] ----- -client.asyncSearch.get({ - id: string, - wait_for_completion_timeout: string, - keep_alive: string, - typed_keys: boolean -}) ----- -link:{ref}/async-search.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The async search ID - -|`wait_for_completion_timeout` or `waitForCompletionTimeout` -|`string` - Specify the time that the request should block waiting for the final response - -|`keep_alive` or `keepAlive` -|`string` - Specify the time interval in which the results (partial or final) for this search will be available - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|=== - -[discrete] -=== asyncSearch.status - -[source,ts] ----- -client.asyncSearch.status({ - id: string -}) ----- -link:{ref}/async-search.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The async search ID - -|=== - -[discrete] -=== asyncSearch.submit - -[source,ts] ----- -client.asyncSearch.submit({ - index: string | string[], - wait_for_completion_timeout: string, - keep_on_completion: boolean, - keep_alive: string, - batched_reduce_size: number, - request_cache: boolean, - analyzer: string, - analyze_wildcard: boolean, - default_operator: 'AND' | 'OR', - df: string, - explain: boolean, - stored_fields: string | string[], - docvalue_fields: string | string[], - from: number, - ignore_unavailable: boolean, - ignore_throttled: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - lenient: boolean, - preference: string, - q: string, - routing: string | string[], - search_type: 'query_then_fetch' | 'dfs_query_then_fetch', - size: number, - sort: string | string[], - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - terminate_after: number, - stats: string | string[], - suggest_field: string, - suggest_mode: 'missing' | 'popular' | 'always', - suggest_size: number, - suggest_text: string, - timeout: string, - track_scores: boolean, - track_total_hits: boolean, - allow_partial_search_results: boolean, - typed_keys: boolean, - version: boolean, - seq_no_primary_term: boolean, - max_concurrent_shard_requests: number, - body: object -}) ----- -link:{ref}/async-search.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`wait_for_completion_timeout` or `waitForCompletionTimeout` -|`string` - Specify the time that the request should block waiting for the final response + -_Default:_ `1s` - -|`keep_on_completion` or `keepOnCompletion` -|`boolean` - Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) - -|`keep_alive` or `keepAlive` -|`string` - Update the time interval in which the results (partial or final) for this search will be available + -_Default:_ `5d` - -|`batched_reduce_size` or `batchedReduceSize` -|`number` - The number of shard results that should be reduced at once on the coordinating node. This value should be used as the granularity at which progress results will be made available. + -_Default:_ `5` - -|`request_cache` or `requestCache` -|`boolean` - Specify if request cache should be used for this request or not, defaults to true - -|`analyzer` -|`string` - The analyzer to use for the query string - -|`analyze_wildcard` or `analyzeWildcard` -|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) - -|`default_operator` or `defaultOperator` -|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + -_Default:_ `OR` - -|`df` -|`string` - The field to use as default where no field prefix is given in the query string - -|`explain` -|`boolean` - Specify whether to return detailed information about score computation as part of a hit - -|`stored_fields` or `storedFields` -|`string \| string[]` - A comma-separated list of stored fields to return as part of a hit - -|`docvalue_fields` or `docvalueFields` -|`string \| string[]` - A comma-separated list of fields to return as the docvalue representation of a field for each hit - -|`from` -|`number` - Starting offset (default: 0) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`ignore_throttled` or `ignoreThrottled` -|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`lenient` -|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`q` -|`string` - Query in the Lucene query string syntax - -|`routing` -|`string \| string[]` - A comma-separated list of specific routing values - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type - -|`size` -|`number` - Number of hits to return (default: 10) - -|`sort` -|`string \| string[]` - A comma-separated list of : pairs - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`terminate_after` or `terminateAfter` -|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. - -|`stats` -|`string \| string[]` - Specific 'tag' of the request for logging and statistical purposes - -|`suggest_field` or `suggestField` -|`string` - Specify which field to use for suggestions - -|`suggest_mode` or `suggestMode` -|`'missing' \| 'popular' \| 'always'` - Specify suggest mode + -_Default:_ `missing` - -|`suggest_size` or `suggestSize` -|`number` - How many suggestions to return in response - -|`suggest_text` or `suggestText` -|`string` - The source text for which the suggestions should be returned - -|`timeout` -|`string` - Explicit operation timeout - -|`track_scores` or `trackScores` -|`boolean` - Whether to calculate and return scores even if they are not used for sorting - -|`track_total_hits` or `trackTotalHits` -|`boolean` - Indicate if the number of documents that match the query should be tracked - -|`allow_partial_search_results` or `allowPartialSearchResults` -|`boolean` - Indicate if an error should be returned if there is a partial search failure or timeout + -_Default:_ `true` - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|`version` -|`boolean` - Specify whether to return document version as part of a hit - -|`seq_no_primary_term` or `seqNoPrimaryTerm` -|`boolean` - Specify whether to return sequence number and primary term of the last modification of each hit - -|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` -|`number` - The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + -_Default:_ `5` - -|`body` -|`object` - The search definition using the Query DSL - -|=== - -[discrete] -=== autoscaling.deleteAutoscalingPolicy - -[source,ts] ----- -client.autoscaling.deleteAutoscalingPolicy({ - name: string -}) ----- -link:{ref}/autoscaling-delete-autoscaling-policy.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - the name of the autoscaling policy - -|=== - -[discrete] -=== autoscaling.getAutoscalingCapacity - -[source,ts] ----- -client.autoscaling.getAutoscalingCapacity() ----- -link:{ref}/autoscaling-get-autoscaling-capacity.html[Documentation] + - - -[discrete] -=== autoscaling.getAutoscalingPolicy - -[source,ts] ----- -client.autoscaling.getAutoscalingPolicy({ - name: string -}) ----- -link:{ref}/autoscaling-get-autoscaling-policy.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - the name of the autoscaling policy - -|=== - -[discrete] -=== autoscaling.putAutoscalingPolicy - -[source,ts] ----- -client.autoscaling.putAutoscalingPolicy({ - name: string, - body: object -}) ----- -link:{ref}/autoscaling-put-autoscaling-policy.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - the name of the autoscaling policy - -|`body` -|`object` - the specification of the autoscaling policy - -|=== - -[discrete] -=== bulk - -[source,ts] ----- -client.bulk({ - index: string, - type: string, - wait_for_active_shards: string, - refresh: 'true' | 'false' | 'wait_for', - routing: string, - timeout: string, - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - pipeline: string, - require_alias: boolean, - body: object -}) ----- -link:{ref}/docs-bulk.html[Documentation] + -{jsclient}/bulk_examples.html[Code Example] + -[cols=2*] -|=== -|`index` -|`string` - Default index for items which don't provide one - -|`type` -|`string` - Default document type for items which don't provide one - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. - -|`routing` -|`string` - Specific routing value - -|`timeout` -|`string` - Explicit operation timeout - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - Default list of fields to exclude from the returned _source field, can be overridden on each sub-request - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - Default list of fields to extract and return from the _source field, can be overridden on each sub-request - -|`pipeline` -|`string` - The pipeline id to preprocess incoming documents with - -|`require_alias` or `requireAlias` -|`boolean` - Sets require_alias for all incoming documents. Defaults to unset (false) - -|`body` -|`object` - The operation definition and data (action-data pairs), separated by newlines - -|=== - -[discrete] -=== cat.aliases - -[source,ts] ----- -client.cat.aliases({ - name: string | string[], - format: string, - local: boolean, - h: string | string[], - help: boolean, - s: string | string[], - v: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/cat-alias.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of alias names to return - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`v` -|`boolean` - Verbose mode. Display column headers - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `all` - -|=== - -[discrete] -=== cat.allocation - -[source,ts] ----- -client.cat.allocation({ - node_id: string | string[], - format: string, - bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - local: boolean, - master_timeout: string, - h: string | string[], - help: boolean, - s: string | string[], - v: boolean -}) ----- -link:{ref}/cat-allocation.html[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`bytes` -|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.count - -[source,ts] ----- -client.cat.count({ - index: string | string[], - format: string, - h: string | string[], - help: boolean, - s: string | string[], - v: boolean -}) ----- -link:{ref}/cat-count.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to limit the returned information - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.fielddata - -[source,ts] ----- -client.cat.fielddata({ - fields: string | string[], - format: string, - bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - h: string | string[], - help: boolean, - s: string | string[], - v: boolean -}) ----- -link:{ref}/cat-fielddata.html[Documentation] + -[cols=2*] -|=== -|`fields` -|`string \| string[]` - A comma-separated list of fields to return the fielddata size - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`bytes` -|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.health - -[source,ts] ----- -client.cat.health({ - format: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - ts: boolean, - v: boolean -}) ----- -link:{ref}/cat-health.html[Documentation] + -[cols=2*] -|=== -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`ts` -|`boolean` - Set to false to disable timestamping + -_Default:_ `true` - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.help - -[source,ts] ----- -client.cat.help({ - help: boolean, - s: string | string[] -}) ----- -link:{ref}/cat.html[Documentation] + -[cols=2*] -|=== -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|=== - -[discrete] -=== cat.indices - -[source,ts] ----- -client.cat.indices({ - index: string | string[], - format: string, - bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - local: boolean, - master_timeout: string, - h: string | string[], - health: 'green' | 'yellow' | 'red', - help: boolean, - pri: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean, - include_unloaded_segments: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/cat-indices.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to limit the returned information - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`bytes` -|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) + - -WARNING: This parameter has been deprecated. - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`health` -|`'green' \| 'yellow' \| 'red'` - A health status ("green", "yellow", or "red" to filter only indices matching the specified health status - -|`help` -|`boolean` - Return help information - -|`pri` -|`boolean` - Set to true to return stats only for primary shards - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|`include_unloaded_segments` or `includeUnloadedSegments` -|`boolean` - If set to true segment stats will include stats for segments that are not currently loaded into memory - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `all` - -|=== - -[discrete] -=== cat.master - -[source,ts] ----- -client.cat.master({ - format: string, - local: boolean, - master_timeout: string, - h: string | string[], - help: boolean, - s: string | string[], - v: boolean -}) ----- -link:{ref}/cat-master.html[Documentation] + -[cols=2*] -|=== -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.mlDataFrameAnalytics - -[source,ts] ----- -client.cat.mlDataFrameAnalytics({ - id: string, - allow_no_match: boolean, - bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - format: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-dfanalytics.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the data frame analytics to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no configs. (This includes `_all` string or when no configs have been specified) - -|`bytes` -|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.mlDatafeeds - -[source,ts] ----- -client.cat.mlDatafeeds({ - datafeed_id: string, - allow_no_match: boolean, - allow_no_datafeeds: boolean, - format: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-datafeeds.html[Documentation] + -[cols=2*] -|=== -|`datafeed_id` or `datafeedId` -|`string` - The ID of the datafeeds stats to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) - -|`allow_no_datafeeds` or `allowNoDatafeeds` -|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + - -WARNING: This parameter has been deprecated. - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.mlJobs - -[source,ts] ----- -client.cat.mlJobs({ - job_id: string, - allow_no_match: boolean, - allow_no_jobs: boolean, - bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - format: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-anomaly-detectors.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the jobs stats to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) - -|`allow_no_jobs` or `allowNoJobs` -|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + - -WARNING: This parameter has been deprecated. - -|`bytes` -|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.mlTrainedModels - -[source,ts] ----- -client.cat.mlTrainedModels({ - model_id: string, - allow_no_match: boolean, - from: number, - size: number, - bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - format: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-trained-model.html[Documentation] + -[cols=2*] -|=== -|`model_id` or `modelId` -|`string` - The ID of the trained models stats to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) + -_Default:_ `true` - -|`from` -|`number` - skips a number of trained models - -|`size` -|`number` - specifies a max number of trained models to get + -_Default:_ `100` - -|`bytes` -|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.nodeattrs - -[source,ts] ----- -client.cat.nodeattrs({ - format: string, - local: boolean, - master_timeout: string, - h: string | string[], - help: boolean, - s: string | string[], - v: boolean -}) ----- -link:{ref}/cat-nodeattrs.html[Documentation] + -[cols=2*] -|=== -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.nodes - -[source,ts] ----- -client.cat.nodes({ - bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - format: string, - full_id: boolean, - local: boolean, - master_timeout: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean, - include_unloaded_segments: boolean -}) ----- -link:{ref}/cat-nodes.html[Documentation] + -[cols=2*] -|=== -|`bytes` -|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`full_id` or `fullId` -|`boolean` - Return the full node ID instead of the shortened version (default: false) - -|`local` -|`boolean` - Calculate the selected nodes using the local cluster state rather than the state from master node (default: false) + - -WARNING: This parameter has been deprecated. - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|`include_unloaded_segments` or `includeUnloadedSegments` -|`boolean` - If set to true segment stats will include stats for segments that are not currently loaded into memory - -|=== - -[discrete] -=== cat.pendingTasks - -[source,ts] ----- -client.cat.pendingTasks({ - format: string, - local: boolean, - master_timeout: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-pending-tasks.html[Documentation] + -[cols=2*] -|=== -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.plugins - -[source,ts] ----- -client.cat.plugins({ - format: string, - local: boolean, - master_timeout: string, - h: string | string[], - help: boolean, - include_bootstrap: boolean, - s: string | string[], - v: boolean -}) ----- -link:{ref}/cat-plugins.html[Documentation] + -[cols=2*] -|=== -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`include_bootstrap` or `includeBootstrap` -|`boolean` - Include bootstrap plugins in the response - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.recovery - -[source,ts] ----- -client.cat.recovery({ - index: string | string[], - format: string, - active_only: boolean, - bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - detailed: boolean, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-recovery.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - Comma-separated list or wildcard expression of index names to limit the returned information - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`active_only` or `activeOnly` -|`boolean` - If `true`, the response only includes ongoing shard recoveries - -|`bytes` -|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values - -|`detailed` -|`boolean` - If `true`, the response includes detailed information about shard recoveries - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.repositories - -[source,ts] ----- -client.cat.repositories({ - format: string, - local: boolean, - master_timeout: string, - h: string | string[], - help: boolean, - s: string | string[], - v: boolean -}) ----- -link:{ref}/cat-repositories.html[Documentation] + -[cols=2*] -|=== -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.segments - -[source,ts] ----- -client.cat.segments({ - index: string | string[], - format: string, - bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - h: string | string[], - help: boolean, - s: string | string[], - v: boolean -}) ----- -link:{ref}/cat-segments.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to limit the returned information - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`bytes` -|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.shards - -[source,ts] ----- -client.cat.shards({ - index: string | string[], - format: string, - bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - local: boolean, - master_timeout: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-shards.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to limit the returned information - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`bytes` -|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) + - -WARNING: This parameter has been deprecated. - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.snapshots - -[source,ts] ----- -client.cat.snapshots({ - repository: string | string[], - format: string, - ignore_unavailable: boolean, - master_timeout: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string \| string[]` - Name of repository from which to fetch the snapshot information - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Set to true to ignore unavailable snapshots - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.tasks - -[source,ts] ----- -client.cat.tasks({ - format: string, - nodes: string | string[], - actions: string | string[], - detailed: boolean, - parent_task_id: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/tasks.html[Documentation] + -[cols=2*] -|=== -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`nodes` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`actions` -|`string \| string[]` - A comma-separated list of actions that should be returned. Leave empty to return all. - -|`detailed` -|`boolean` - Return detailed task information (default: false) - -|`parent_task_id` or `parentTaskId` -|`string` - Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.templates - -[source,ts] ----- -client.cat.templates({ - name: string, - format: string, - local: boolean, - master_timeout: string, - h: string | string[], - help: boolean, - s: string | string[], - v: boolean -}) ----- -link:{ref}/cat-templates.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - A pattern that returned template names must match - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.threadPool - -[source,ts] ----- -client.cat.threadPool({ - thread_pool_patterns: string | string[], - format: string, - size: '' | 'k' | 'm' | 'g' | 't' | 'p', - local: boolean, - master_timeout: string, - h: string | string[], - help: boolean, - s: string | string[], - v: boolean -}) ----- -link:{ref}/cat-thread-pool.html[Documentation] + -[cols=2*] -|=== -|`thread_pool_patterns` or `threadPoolPatterns` -|`string \| string[]` - A comma-separated list of regular-expressions to filter the thread pools in the output - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`size` -|`'' \| 'k' \| 'm' \| 'g' \| 't' \| 'p'` - The multiplier in which to display values + - -WARNING: This parameter has been deprecated. - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== cat.transforms - -[source,ts] ----- -client.cat.transforms({ - transform_id: string, - from: number, - size: number, - allow_no_match: boolean, - format: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-transforms.html[Documentation] + -[cols=2*] -|=== -|`transform_id` or `transformId` -|`string` - The id of the transform for which to get stats. '_all' or '*' implies all transforms - -|`from` -|`number` - skips a number of transform configs, defaults to 0 - -|`size` -|`number` - specifies a max number of transforms to get, defaults to 100 - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -[discrete] -=== ccr.deleteAutoFollowPattern - -[source,ts] ----- -client.ccr.deleteAutoFollowPattern({ - name: string -}) ----- -link:{ref}/ccr-delete-auto-follow-pattern.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the auto follow pattern. - -|=== - -[discrete] -=== ccr.follow - -[source,ts] ----- -client.ccr.follow({ - index: string, - wait_for_active_shards: string, - body: object -}) ----- -link:{ref}/ccr-put-follow.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the follower index - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of shard copies that must be active before returning. Defaults to 0. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + -_Default:_ `0` - -|`body` -|`object` - The name of the leader index and other optional ccr related parameters - -|=== - -[discrete] -=== ccr.followInfo - -[source,ts] ----- -client.ccr.followInfo({ - index: string | string[] -}) ----- -link:{ref}/ccr-get-follow-info.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index patterns; use `_all` to perform the operation on all indices - -|=== - -[discrete] -=== ccr.followStats - -[source,ts] ----- -client.ccr.followStats({ - index: string | string[] -}) ----- -link:{ref}/ccr-get-follow-stats.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index patterns; use `_all` to perform the operation on all indices - -|=== - -[discrete] -=== ccr.forgetFollower - -[source,ts] ----- -client.ccr.forgetFollower({ - index: string, - body: object -}) ----- -link:{ref}/ccr-post-forget-follower.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - the name of the leader index for which specified follower retention leases should be removed - -|`body` -|`object` - the name and UUID of the follower index, the name of the cluster containing the follower index, and the alias from the perspective of that cluster for the remote cluster containing the leader index - -|=== - -[discrete] -=== ccr.getAutoFollowPattern - -[source,ts] ----- -client.ccr.getAutoFollowPattern({ - name: string -}) ----- -link:{ref}/ccr-get-auto-follow-pattern.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the auto follow pattern. - -|=== - -[discrete] -=== ccr.pauseAutoFollowPattern - -[source,ts] ----- -client.ccr.pauseAutoFollowPattern({ - name: string -}) ----- -link:{ref}/ccr-pause-auto-follow-pattern.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the auto follow pattern that should pause discovering new indices to follow. - -|=== - -[discrete] -=== ccr.pauseFollow - -[source,ts] ----- -client.ccr.pauseFollow({ - index: string -}) ----- -link:{ref}/ccr-post-pause-follow.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the follower index that should pause following its leader index. - -|=== - -[discrete] -=== ccr.putAutoFollowPattern - -[source,ts] ----- -client.ccr.putAutoFollowPattern({ - name: string, - body: object -}) ----- -link:{ref}/ccr-put-auto-follow-pattern.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the auto follow pattern. - -|`body` -|`object` - The specification of the auto follow pattern - -|=== - -[discrete] -=== ccr.resumeAutoFollowPattern - -[source,ts] ----- -client.ccr.resumeAutoFollowPattern({ - name: string -}) ----- -link:{ref}/ccr-resume-auto-follow-pattern.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the auto follow pattern to resume discovering new indices to follow. - -|=== - -[discrete] -=== ccr.resumeFollow - -[source,ts] ----- -client.ccr.resumeFollow({ - index: string, - body: object -}) ----- -link:{ref}/ccr-post-resume-follow.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the follow index to resume following. - -|`body` -|`object` - The name of the leader index and other optional ccr related parameters - -|=== - -[discrete] -=== ccr.stats - -[source,ts] ----- -client.ccr.stats() ----- -link:{ref}/ccr-get-stats.html[Documentation] + - - -[discrete] -=== ccr.unfollow - -[source,ts] ----- -client.ccr.unfollow({ - index: string -}) ----- -link:{ref}/ccr-post-unfollow.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the follower index that should be turned into a regular index. - -|=== - -[discrete] -=== clearScroll - -[source,ts] ----- -client.clearScroll({ - scroll_id: string | string[], - body: object -}) ----- -link:{ref}/clear-scroll-api.html[Documentation] + -[cols=2*] -|=== -|`scroll_id` or `scrollId` -|`string \| string[]` - A comma-separated list of scroll IDs to clear + - -WARNING: This parameter has been deprecated. - -|`body` -|`object` - A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter - -|=== - -[discrete] -=== closePointInTime - -[source,ts] ----- -client.closePointInTime({ - body: object -}) ----- -link:{ref}/point-in-time-api.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - a point-in-time id to close - -|=== - -[discrete] -=== cluster.allocationExplain - -[source,ts] ----- -client.cluster.allocationExplain({ - include_yes_decisions: boolean, - include_disk_info: boolean, - body: object -}) ----- -link:{ref}/cluster-allocation-explain.html[Documentation] + -[cols=2*] -|=== -|`include_yes_decisions` or `includeYesDecisions` -|`boolean` - Return 'YES' decisions in explanation (default: false) - -|`include_disk_info` or `includeDiskInfo` -|`boolean` - Return information about disk usage and shard sizes (default: false) - -|`body` -|`object` - The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard' - -|=== - -[discrete] -=== cluster.deleteComponentTemplate - -[source,ts] ----- -client.cluster.deleteComponentTemplate({ - name: string, - timeout: string, - master_timeout: string -}) ----- -link:{ref}/indices-component-template.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the template - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|=== - -[discrete] -=== cluster.deleteVotingConfigExclusions - -[source,ts] ----- -client.cluster.deleteVotingConfigExclusions({ - wait_for_removal: boolean -}) ----- -link:{ref}/voting-config-exclusions.html[Documentation] + -[cols=2*] -|=== -|`wait_for_removal` or `waitForRemoval` -|`boolean` - Specifies whether to wait for all excluded nodes to be removed from the cluster before clearing the voting configuration exclusions list. + -_Default:_ `true` - -|=== - -[discrete] -=== cluster.existsComponentTemplate - -[source,ts] ----- -client.cluster.existsComponentTemplate({ - name: string, - master_timeout: string, - local: boolean -}) ----- -link:{ref}/indices-component-template.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the template - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|=== - -[discrete] -=== cluster.getComponentTemplate - -[source,ts] ----- -client.cluster.getComponentTemplate({ - name: string | string[], - master_timeout: string, - local: boolean -}) ----- -link:{ref}/indices-component-template.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - The comma separated names of the component templates - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|=== - -[discrete] -=== cluster.getSettings - -[source,ts] ----- -client.cluster.getSettings({ - flat_settings: boolean, - master_timeout: string, - timeout: string, - include_defaults: boolean -}) ----- -link:{ref}/cluster-get-settings.html[Documentation] + -[cols=2*] -|=== -|`flat_settings` or `flatSettings` -|`boolean` - Return settings in flat format (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|`include_defaults` or `includeDefaults` -|`boolean` - Whether to return all default clusters setting. - -|=== - -[discrete] -=== cluster.health - -[source,ts] ----- -client.cluster.health({ - index: string | string[], - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - level: 'cluster' | 'indices' | 'shards', - local: boolean, - master_timeout: string, - timeout: string, - wait_for_active_shards: string, - wait_for_nodes: string, - wait_for_events: 'immediate' | 'urgent' | 'high' | 'normal' | 'low' | 'languid', - wait_for_no_relocating_shards: boolean, - wait_for_no_initializing_shards: boolean, - wait_for_status: 'green' | 'yellow' | 'red' -}) ----- -link:{ref}/cluster-health.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - Limit the information returned to a specific index - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `all` - -|`level` -|`'cluster' \| 'indices' \| 'shards'` - Specify the level of detail for returned information + -_Default:_ `cluster` - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Wait until the specified number of shards is active - -|`wait_for_nodes` or `waitForNodes` -|`string` - Wait until the specified number of nodes is available - -|`wait_for_events` or `waitForEvents` -|`'immediate' \| 'urgent' \| 'high' \| 'normal' \| 'low' \| 'languid'` - Wait until all currently queued events with the given priority are processed - -|`wait_for_no_relocating_shards` or `waitForNoRelocatingShards` -|`boolean` - Whether to wait until there are no relocating shards in the cluster - -|`wait_for_no_initializing_shards` or `waitForNoInitializingShards` -|`boolean` - Whether to wait until there are no initializing shards in the cluster - -|`wait_for_status` or `waitForStatus` -|`'green' \| 'yellow' \| 'red'` - Wait until cluster is in a specific state - -|=== - -[discrete] -=== cluster.pendingTasks - -[source,ts] ----- -client.cluster.pendingTasks({ - local: boolean, - master_timeout: string -}) ----- -link:{ref}/cluster-pending.html[Documentation] + -[cols=2*] -|=== -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|=== - -[discrete] -=== cluster.postVotingConfigExclusions - -[source,ts] ----- -client.cluster.postVotingConfigExclusions({ - node_ids: string, - node_names: string, - timeout: string -}) ----- -link:{ref}/voting-config-exclusions.html[Documentation] + -[cols=2*] -|=== -|`node_ids` or `nodeIds` -|`string` - A comma-separated list of the persistent ids of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_names. - -|`node_names` or `nodeNames` -|`string` - A comma-separated list of the names of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_ids. - -|`timeout` -|`string` - Explicit operation timeout + -_Default:_ `30s` - -|=== - -[discrete] -=== cluster.putComponentTemplate - -[source,ts] ----- -client.cluster.putComponentTemplate({ - name: string, - create: boolean, - timeout: string, - master_timeout: string, - body: object -}) ----- -link:{ref}/indices-component-template.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the template - -|`create` -|`boolean` - Whether the index template should only be added if new or can also replace an existing one - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`body` -|`object` - The template definition - -|=== - -[discrete] -=== cluster.putSettings - -[source,ts] ----- -client.cluster.putSettings({ - flat_settings: boolean, - master_timeout: string, - timeout: string, - body: object -}) ----- -link:{ref}/cluster-update-settings.html[Documentation] + -[cols=2*] -|=== -|`flat_settings` or `flatSettings` -|`boolean` - Return settings in flat format (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|`body` -|`object` - The settings to be updated. Can be either `transient` or `persistent` (survives cluster restart). - -|=== - -[discrete] -=== cluster.remoteInfo - -[source,ts] ----- -client.cluster.remoteInfo() ----- -link:{ref}/cluster-remote-info.html[Documentation] + - - -[discrete] -=== cluster.reroute - -[source,ts] ----- -client.cluster.reroute({ - dry_run: boolean, - explain: boolean, - retry_failed: boolean, - metric: string | string[], - master_timeout: string, - timeout: string, - body: object -}) ----- -link:{ref}/cluster-reroute.html[Documentation] + -[cols=2*] -|=== -|`dry_run` or `dryRun` -|`boolean` - Simulate the operation only and return the resulting state - -|`explain` -|`boolean` - Return an explanation of why the commands can or cannot be executed - -|`retry_failed` or `retryFailed` -|`boolean` - Retries allocation of shards that are blocked due to too many subsequent allocation failures - -|`metric` -|`string \| string[]` - Limit the information returned to the specified metrics. Defaults to all but metadata - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|`body` -|`object` - The definition of `commands` to perform (`move`, `cancel`, `allocate`) - -|=== - -[discrete] -=== cluster.state - -[source,ts] ----- -client.cluster.state({ - index: string | string[], - metric: string | string[], - local: boolean, - master_timeout: string, - flat_settings: boolean, - wait_for_metadata_version: number, - wait_for_timeout: string, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/cluster-state.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - -|`metric` -|`string \| string[]` - Limit the information returned to the specified metrics - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`flat_settings` or `flatSettings` -|`boolean` - Return settings in flat format (default: false) - -|`wait_for_metadata_version` or `waitForMetadataVersion` -|`number` - Wait for the metadata version to be equal or greater than the specified metadata version - -|`wait_for_timeout` or `waitForTimeout` -|`string` - The maximum time to wait for wait_for_metadata_version before timing out - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - -[discrete] -=== cluster.stats - -[source,ts] ----- -client.cluster.stats({ - node_id: string | string[], - flat_settings: boolean, - timeout: string -}) ----- -link:{ref}/cluster-stats.html[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`flat_settings` or `flatSettings` -|`boolean` - Return settings in flat format (default: false) - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -[discrete] -=== count - -[source,ts] ----- -client.count({ - index: string | string[], - type: string | string[], - ignore_unavailable: boolean, - ignore_throttled: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - min_score: number, - preference: string, - routing: string | string[], - q: string, - analyzer: string, - analyze_wildcard: boolean, - default_operator: 'AND' | 'OR', - df: string, - lenient: boolean, - terminate_after: number, - body: object -}) ----- -link:{ref}/search-count.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of indices to restrict the results - -|`type` -|`string \| string[]` - A comma-separated list of types to restrict the results - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`ignore_throttled` or `ignoreThrottled` -|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`min_score` or `minScore` -|`number` - Include only documents with a specific `_score` value in the result - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`routing` -|`string \| string[]` - A comma-separated list of specific routing values - -|`q` -|`string` - Query in the Lucene query string syntax - -|`analyzer` -|`string` - The analyzer to use for the query string - -|`analyze_wildcard` or `analyzeWildcard` -|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) - -|`default_operator` or `defaultOperator` -|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + -_Default:_ `OR` - -|`df` -|`string` - The field to use as default where no field prefix is given in the query string - -|`lenient` -|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - -|`terminate_after` or `terminateAfter` -|`number` - The maximum count for each shard, upon reaching which the query execution will terminate early - -|`body` -|`object` - A query to restrict the results specified with the Query DSL (optional) - -|=== - -[discrete] -=== create - -[source,ts] ----- -client.create({ - id: string, - index: string, - type: string, - wait_for_active_shards: string, - refresh: 'true' | 'false' | 'wait_for', - routing: string, - timeout: string, - version: number, - version_type: 'internal' | 'external' | 'external_gte', - pipeline: string, - body: object -}) ----- -link:{ref}/docs-index_.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - Document ID - -|`index` -|`string` - The name of the index - -|`type` -|`string` - The type of the document + - -WARNING: This parameter has been deprecated. - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. - -|`routing` -|`string` - Specific routing value - -|`timeout` -|`string` - Explicit operation timeout - -|`version` -|`number` - Explicit version number for concurrency control - -|`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte'` - Specific version type - -|`pipeline` -|`string` - The pipeline id to preprocess incoming documents with - -|`body` -|`object` - The document - -|=== - -[discrete] -=== danglingIndices.deleteDanglingIndex - -[source,ts] ----- -client.danglingIndices.deleteDanglingIndex({ - index_uuid: string, - accept_data_loss: boolean, - timeout: string, - master_timeout: string -}) ----- -link:{ref}/modules-gateway-dangling-indices.html[Documentation] + -[cols=2*] -|=== -|`index_uuid` or `indexUuid` -|`string` - The UUID of the dangling index - -|`accept_data_loss` or `acceptDataLoss` -|`boolean` - Must be set to true in order to delete the dangling index - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|=== - -[discrete] -=== danglingIndices.importDanglingIndex - -[source,ts] ----- -client.danglingIndices.importDanglingIndex({ - index_uuid: string, - accept_data_loss: boolean, - timeout: string, - master_timeout: string -}) ----- -link:{ref}/modules-gateway-dangling-indices.html[Documentation] + -[cols=2*] -|=== -|`index_uuid` or `indexUuid` -|`string` - The UUID of the dangling index - -|`accept_data_loss` or `acceptDataLoss` -|`boolean` - Must be set to true in order to import the dangling index - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|=== - -[discrete] -=== danglingIndices.listDanglingIndices - -[source,ts] ----- -client.danglingIndices.listDanglingIndices() ----- -link:{ref}/modules-gateway-dangling-indices.html[Documentation] + - - -[discrete] -=== delete - -[source,ts] ----- -client.delete({ - id: string, - index: string, - type: string, - wait_for_active_shards: string, - refresh: 'true' | 'false' | 'wait_for', - routing: string, - timeout: string, - if_seq_no: number, - if_primary_term: number, - version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force' -}) ----- -link:{ref}/docs-delete.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The document ID - -|`index` -|`string` - The name of the index - -|`type` -|`string` - The type of the document + - -WARNING: This parameter has been deprecated. - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. - -|`routing` -|`string` - Specific routing value - -|`timeout` -|`string` - Explicit operation timeout - -|`if_seq_no` or `ifSeqNo` -|`number` - only perform the delete operation if the last operation that has changed the document has the specified sequence number - -|`if_primary_term` or `ifPrimaryTerm` -|`number` - only perform the delete operation if the last operation that has changed the document has the specified primary term - -|`version` -|`number` - Explicit version number for concurrency control - -|`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type - -|=== - -[discrete] -=== deleteByQuery - -[source,ts] ----- -client.deleteByQuery({ - index: string | string[], - type: string | string[], - analyzer: string, - analyze_wildcard: boolean, - default_operator: 'AND' | 'OR', - df: string, - from: number, - ignore_unavailable: boolean, - allow_no_indices: boolean, - conflicts: 'abort' | 'proceed', - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - lenient: boolean, - preference: string, - q: string, - routing: string | string[], - scroll: string, - search_type: 'query_then_fetch' | 'dfs_query_then_fetch', - search_timeout: string, - size: number, - max_docs: number, - sort: string | string[], - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - terminate_after: number, - stats: string | string[], - version: boolean, - request_cache: boolean, - refresh: boolean, - timeout: string, - wait_for_active_shards: string, - scroll_size: number, - wait_for_completion: boolean, - requests_per_second: number, - slices: number|string, - body: object -}) ----- -link:{ref}/docs-delete-by-query.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`type` -|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types - -|`analyzer` -|`string` - The analyzer to use for the query string - -|`analyze_wildcard` or `analyzeWildcard` -|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) - -|`default_operator` or `defaultOperator` -|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + -_Default:_ `OR` - -|`df` -|`string` - The field to use as default where no field prefix is given in the query string - -|`from` -|`number` - Starting offset (default: 0) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`conflicts` -|`'abort' \| 'proceed'` - What to do when the delete by query hits version conflicts? + -_Default:_ `abort` - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`lenient` -|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`q` -|`string` - Query in the Lucene query string syntax - -|`routing` -|`string \| string[]` - A comma-separated list of specific routing values - -|`scroll` -|`string` - Specify how long a consistent view of the index should be maintained for scrolled search - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type - -|`search_timeout` or `searchTimeout` -|`string` - Explicit timeout for each search request. Defaults to no timeout. - -|`size` -|`number` - Deprecated, please use `max_docs` instead - -|`max_docs` or `maxDocs` -|`number` - Maximum number of documents to process (default: all documents) - -|`sort` -|`string \| string[]` - A comma-separated list of : pairs - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`terminate_after` or `terminateAfter` -|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. - -|`stats` -|`string \| string[]` - Specific 'tag' of the request for logging and statistical purposes - -|`version` -|`boolean` - Specify whether to return document version as part of a hit - -|`request_cache` or `requestCache` -|`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting - -|`refresh` -|`boolean` - Should the effected indexes be refreshed? - -|`timeout` -|`string` - Time each individual bulk request should wait for shards that are unavailable. + -_Default:_ `1m` - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - -|`scroll_size` or `scrollSize` -|`number` - Size on the scroll request powering the delete by query + -_Default:_ `100` - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should the request should block until the delete by query is complete. + -_Default:_ `true` - -|`requests_per_second` or `requestsPerSecond` -|`number` - The throttle for this request in sub-requests per second. -1 means no throttle. - -|`slices` -|`number\|string` - The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. + -_Default:_ `1` - -|`body` -|`object` - The search definition using the Query DSL - -|=== - -[discrete] -=== deleteByQueryRethrottle - -[source,ts] ----- -client.deleteByQueryRethrottle({ - task_id: string, - requests_per_second: number -}) ----- -link:{ref}/docs-delete-by-query.html[Documentation] + -[cols=2*] -|=== -|`task_id` or `taskId` -|`string` - The task id to rethrottle - -|`requests_per_second` or `requestsPerSecond` -|`number` - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. - -|=== - -[discrete] -=== deleteScript - -[source,ts] ----- -client.deleteScript({ - id: string, - timeout: string, - master_timeout: string -}) ----- -link:{ref}/modules-scripting.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - Script ID - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|=== - -[discrete] -=== enrich.deletePolicy - -[source,ts] ----- -client.enrich.deletePolicy({ - name: string -}) ----- -link:{ref}/delete-enrich-policy-api.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the enrich policy - -|=== - -[discrete] -=== enrich.executePolicy - -[source,ts] ----- -client.enrich.executePolicy({ - name: string, - wait_for_completion: boolean -}) ----- -link:{ref}/execute-enrich-policy-api.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the enrich policy - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should the request should block until the execution is complete. + -_Default:_ `true` - -|=== - -[discrete] -=== enrich.getPolicy - -[source,ts] ----- -client.enrich.getPolicy({ - name: string | string[] -}) ----- -link:{ref}/get-enrich-policy-api.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of enrich policy names - -|=== - -[discrete] -=== enrich.putPolicy - -[source,ts] ----- -client.enrich.putPolicy({ - name: string, - body: object -}) ----- -link:{ref}/put-enrich-policy-api.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the enrich policy - -|`body` -|`object` - The enrich policy to register - -|=== - -[discrete] -=== enrich.stats - -[source,ts] ----- -client.enrich.stats() ----- -link:{ref}/enrich-stats-api.html[Documentation] + - - -[discrete] -=== eql.delete - -[source,ts] ----- -client.eql.delete({ - id: string -}) ----- -link:{ref}/eql-search-api.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The async search ID - -|=== - -[discrete] -=== eql.get - -[source,ts] ----- -client.eql.get({ - id: string, - wait_for_completion_timeout: string, - keep_alive: string -}) ----- -link:{ref}/eql-search-api.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The async search ID - -|`wait_for_completion_timeout` or `waitForCompletionTimeout` -|`string` - Specify the time that the request should block waiting for the final response - -|`keep_alive` or `keepAlive` -|`string` - Update the time interval in which the results (partial or final) for this search will be available + -_Default:_ `5d` - -|=== - -[discrete] -=== eql.getStatus - -[source,ts] ----- -client.eql.getStatus({ - id: string -}) ----- -link:{ref}/eql-search-api.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The async search ID - -|=== - -[discrete] -=== eql.search - -[source,ts] ----- -client.eql.search({ - index: string, - wait_for_completion_timeout: string, - keep_on_completion: boolean, - keep_alive: string, - body: object -}) ----- -link:{ref}/eql-search-api.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index to scope the operation - -|`wait_for_completion_timeout` or `waitForCompletionTimeout` -|`string` - Specify the time that the request should block waiting for the final response - -|`keep_on_completion` or `keepOnCompletion` -|`boolean` - Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) - -|`keep_alive` or `keepAlive` -|`string` - Update the time interval in which the results (partial or final) for this search will be available + -_Default:_ `5d` - -|`body` -|`object` - Eql request body. Use the `query` to limit the query scope. - -|=== - -[discrete] -=== exists - -[source,ts] ----- -client.exists({ - id: string, - index: string, - type: string, - stored_fields: string | string[], - preference: string, - realtime: boolean, - refresh: boolean, - routing: string, - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force' -}) ----- -link:{ref}/docs-get.html[Documentation] + -{jsclient}/exists_examples.html[Code Example] + -[cols=2*] -|=== -|`id` -|`string` - The document ID - -|`index` -|`string` - The name of the index - -|`type` -|`string` - The type of the document (use `_all` to fetch the first document matching the ID across all types) + - -WARNING: This parameter has been deprecated. - -|`stored_fields` or `storedFields` -|`string \| string[]` - A comma-separated list of stored fields to return in the response - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`realtime` -|`boolean` - Specify whether to perform the operation in realtime or search mode - -|`refresh` -|`boolean` - Refresh the shard containing the document before performing the operation - -|`routing` -|`string` - Specific routing value - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`version` -|`number` - Explicit version number for concurrency control - -|`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type - -|=== - -[discrete] -=== existsSource - -[source,ts] ----- -client.existsSource({ - id: string, - index: string, - type: string, - preference: string, - realtime: boolean, - refresh: boolean, - routing: string, - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force' -}) ----- -link:{ref}/docs-get.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The document ID - -|`index` -|`string` - The name of the index - -|`type` -|`string` - The type of the document; deprecated and optional starting with 7.0 + - -WARNING: This parameter has been deprecated. - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`realtime` -|`boolean` - Specify whether to perform the operation in realtime or search mode - -|`refresh` -|`boolean` - Refresh the shard containing the document before performing the operation - -|`routing` -|`string` - Specific routing value - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`version` -|`number` - Explicit version number for concurrency control - -|`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type - -|=== - -[discrete] -=== explain - -[source,ts] ----- -client.explain({ - id: string, - index: string, - type: string, - analyze_wildcard: boolean, - analyzer: string, - default_operator: 'AND' | 'OR', - df: string, - stored_fields: string | string[], - lenient: boolean, - preference: string, - q: string, - routing: string, - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - body: object -}) ----- -link:{ref}/search-explain.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The document ID - -|`index` -|`string` - The name of the index - -|`type` -|`string` - The type of the document + - -WARNING: This parameter has been deprecated. - -|`analyze_wildcard` or `analyzeWildcard` -|`boolean` - Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false) - -|`analyzer` -|`string` - The analyzer for the query string query - -|`default_operator` or `defaultOperator` -|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + -_Default:_ `OR` - -|`df` -|`string` - The default field for query string query (default: _all) - -|`stored_fields` or `storedFields` -|`string \| string[]` - A comma-separated list of stored fields to return in the response - -|`lenient` -|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`q` -|`string` - Query in the Lucene query string syntax - -|`routing` -|`string` - Specific routing value - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`body` -|`object` - The query definition using the Query DSL - -|=== - -[discrete] -=== features.getFeatures - -[source,ts] ----- -client.features.getFeatures({ - master_timeout: string -}) ----- -link:{ref}/get-features-api.html[Documentation] + -[cols=2*] -|=== -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|=== - -[discrete] -=== features.resetFeatures -*Stability:* experimental -[source,ts] ----- -client.features.resetFeatures() ----- -link:{ref}/modules-snapshots.html[Documentation] + - - -[discrete] -=== fieldCaps - -[source,ts] ----- -client.fieldCaps({ - index: string | string[], - fields: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - include_unmapped: boolean, - body: object -}) ----- -link:{ref}/search-field-caps.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - -|`fields` -|`string \| string[]` - A comma-separated list of field names - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`include_unmapped` or `includeUnmapped` -|`boolean` - Indicates whether unmapped fields should be included in the response. - -|`body` -|`object` - An index filter specified with the Query DSL - -|=== - -[discrete] -=== fleet.globalCheckpoints -*Stability:* experimental -[source,ts] ----- -client.fleet.globalCheckpoints({ - index: string, - wait_for_advance: boolean, - wait_for_index: boolean, - checkpoints: string | string[], - timeout: string -}) ----- -[cols=2*] -|=== -|`index` -|`string` - The name of the index. - -|`wait_for_advance` or `waitForAdvance` -|`boolean` - Whether to wait for the global checkpoint to advance past the specified current checkpoints + -_Default:_ `false` - -|`wait_for_index` or `waitForIndex` -|`boolean` - Whether to wait for the target index to exist and all primary shards be active + -_Default:_ `false` - -|`checkpoints` -|`string \| string[]` - Comma separated list of checkpoints - -|`timeout` -|`string` - Timeout to wait for global checkpoint to advance + -_Default:_ `30s` - -|=== - -[discrete] -=== get - -[source,ts] ----- -client.get({ - id: string, - index: string, - type: string, - stored_fields: string | string[], - preference: string, - realtime: boolean, - refresh: boolean, - routing: string, - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force' -}) ----- -link:{ref}/docs-get.html[Documentation] + -{jsclient}/get_examples.html[Code Example] + -[cols=2*] -|=== -|`id` -|`string` - The document ID - -|`index` -|`string` - The name of the index - -|`type` -|`string` - The type of the document (use `_all` to fetch the first document matching the ID across all types) + - -WARNING: This parameter has been deprecated. - -|`stored_fields` or `storedFields` -|`string \| string[]` - A comma-separated list of stored fields to return in the response - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`realtime` -|`boolean` - Specify whether to perform the operation in realtime or search mode - -|`refresh` -|`boolean` - Refresh the shard containing the document before performing the operation - -|`routing` -|`string` - Specific routing value - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`version` -|`number` - Explicit version number for concurrency control - -|`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type - -|=== - -[discrete] -=== getScript - -[source,ts] ----- -client.getScript({ - id: string, - master_timeout: string -}) ----- -link:{ref}/modules-scripting.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - Script ID - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|=== - -[discrete] -=== getScriptContext -*Stability:* experimental -[source,ts] ----- -client.getScriptContext() ----- -link:https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-contexts.html[Documentation] + - - -[discrete] -=== getScriptLanguages -*Stability:* experimental -[source,ts] ----- -client.getScriptLanguages() ----- -link:{ref}/modules-scripting.html[Documentation] + - - -[discrete] -=== getSource - -[source,ts] ----- -client.getSource({ - id: string, - index: string, - type: string, - preference: string, - realtime: boolean, - refresh: boolean, - routing: string, - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force' -}) ----- -link:{ref}/docs-get.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The document ID - -|`index` -|`string` - The name of the index - -|`type` -|`string` - The type of the document; deprecated and optional starting with 7.0 + - -WARNING: This parameter has been deprecated. - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`realtime` -|`boolean` - Specify whether to perform the operation in realtime or search mode - -|`refresh` -|`boolean` - Refresh the shard containing the document before performing the operation - -|`routing` -|`string` - Specific routing value - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`version` -|`number` - Explicit version number for concurrency control - -|`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type - -|=== - -[discrete] -=== graph.explore - -[source,ts] ----- -client.graph.explore({ - index: string | string[], - type: string | string[], - routing: string, - timeout: string, - body: object -}) ----- -link:{ref}/graph-explore-api.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`type` -|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + - -WARNING: This parameter has been deprecated. - -|`routing` -|`string` - Specific routing value - -|`timeout` -|`string` - Explicit operation timeout - -|`body` -|`object` - Graph Query DSL - -|=== - -[discrete] -=== ilm.deleteLifecycle - -[source,ts] ----- -client.ilm.deleteLifecycle({ - policy: string -}) ----- -link:{ref}/ilm-delete-lifecycle.html[Documentation] + -[cols=2*] -|=== -|`policy` -|`string` - The name of the index lifecycle policy - -|=== - -[discrete] -=== ilm.explainLifecycle - -[source,ts] ----- -client.ilm.explainLifecycle({ - index: string, - only_managed: boolean, - only_errors: boolean -}) ----- -link:{ref}/ilm-explain-lifecycle.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index to explain - -|`only_managed` or `onlyManaged` -|`boolean` - filters the indices included in the response to ones managed by ILM - -|`only_errors` or `onlyErrors` -|`boolean` - filters the indices included in the response to ones in an ILM error state, implies only_managed - -|=== - -[discrete] -=== ilm.getLifecycle - -[source,ts] ----- -client.ilm.getLifecycle({ - policy: string -}) ----- -link:{ref}/ilm-get-lifecycle.html[Documentation] + -[cols=2*] -|=== -|`policy` -|`string` - The name of the index lifecycle policy - -|=== - -[discrete] -=== ilm.getStatus - -[source,ts] ----- -client.ilm.getStatus() ----- -link:{ref}/ilm-get-status.html[Documentation] + - - -[discrete] -=== ilm.migrateToDataTiers - -[source,ts] ----- -client.ilm.migrateToDataTiers({ - dry_run: boolean, - body: object -}) ----- -link:{ref}/ilm-migrate-to-data-tiers.html[Documentation] + -[cols=2*] -|=== -|`dry_run` or `dryRun` -|`boolean` - If set to true it will simulate the migration, providing a way to retrieve the ILM policies and indices that need to be migrated. The default is false - -|`body` -|`object` - Optionally specify a legacy index template name to delete and optionally specify a node attribute name used for index shard routing (defaults to "data") - -|=== - -[discrete] -=== ilm.moveToStep - -[source,ts] ----- -client.ilm.moveToStep({ - index: string, - body: object -}) ----- -link:{ref}/ilm-move-to-step.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index whose lifecycle step is to change - -|`body` -|`object` - The new lifecycle step to move to - -|=== - -[discrete] -=== ilm.putLifecycle - -[source,ts] ----- -client.ilm.putLifecycle({ - policy: string, - body: object -}) ----- -link:{ref}/ilm-put-lifecycle.html[Documentation] + -[cols=2*] -|=== -|`policy` -|`string` - The name of the index lifecycle policy - -|`body` -|`object` - The lifecycle policy definition to register - -|=== - -[discrete] -=== ilm.removePolicy - -[source,ts] ----- -client.ilm.removePolicy({ - index: string -}) ----- -link:{ref}/ilm-remove-policy.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index to remove policy on - -|=== - -[discrete] -=== ilm.retry - -[source,ts] ----- -client.ilm.retry({ - index: string -}) ----- -link:{ref}/ilm-retry-policy.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the indices (comma-separated) whose failed lifecycle step is to be retry - -|=== - -[discrete] -=== ilm.start - -[source,ts] ----- -client.ilm.start() ----- -link:{ref}/ilm-start.html[Documentation] + - - -[discrete] -=== ilm.stop - -[source,ts] ----- -client.ilm.stop() ----- -link:{ref}/ilm-stop.html[Documentation] + - - -[discrete] -=== index - -[source,ts] ----- -client.index({ - id: string, - index: string, - type: string, - wait_for_active_shards: string, - op_type: 'index' | 'create', - refresh: 'true' | 'false' | 'wait_for', - routing: string, - timeout: string, - version: number, - version_type: 'internal' | 'external' | 'external_gte', - if_seq_no: number, - if_primary_term: number, - pipeline: string, - require_alias: boolean, - body: object -}) ----- -link:{ref}/docs-index_.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - Document ID - -|`index` -|`string` - The name of the index - -|`type` -|`string` - The type of the document + - -WARNING: This parameter has been deprecated. - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - -|`op_type` or `opType` -|`'index' \| 'create'` - Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. - -|`routing` -|`string` - Specific routing value - -|`timeout` -|`string` - Explicit operation timeout - -|`version` -|`number` - Explicit version number for concurrency control - -|`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte'` - Specific version type - -|`if_seq_no` or `ifSeqNo` -|`number` - only perform the index operation if the last operation that has changed the document has the specified sequence number - -|`if_primary_term` or `ifPrimaryTerm` -|`number` - only perform the index operation if the last operation that has changed the document has the specified primary term - -|`pipeline` -|`string` - The pipeline id to preprocess incoming documents with - -|`require_alias` or `requireAlias` -|`boolean` - When true, requires destination to be an alias. Default is false - -|`body` -|`object` - The document - -|=== - -[discrete] -=== indices.addBlock - -[source,ts] ----- -client.indices.addBlock({ - index: string | string[], - block: string, - timeout: string, - master_timeout: string, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/index-modules-blocks.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma separated list of indices to add a block to - -|`block` -|`string` - The block to add (one of read, write, read_only or metadata) - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - -[discrete] -=== indices.analyze - -[source,ts] ----- -client.indices.analyze({ - index: string, - body: object -}) ----- -link:{ref}/indices-analyze.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index to scope the operation - -|`body` -|`object` - Define analyzer/tokenizer parameters and the text on which the analysis should be performed - -|=== - -[discrete] -=== indices.clearCache - -[source,ts] ----- -client.indices.clearCache({ - index: string | string[], - fielddata: boolean, - fields: string | string[], - query: boolean, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - request: boolean -}) ----- -link:{ref}/indices-clearcache.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index name to limit the operation - -|`fielddata` -|`boolean` - Clear field data - -|`fields` -|`string \| string[]` - A comma-separated list of fields to clear when using the `fielddata` parameter (default: all) - -|`query` -|`boolean` - Clear query caches - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`request` -|`boolean` - Clear request cache - -|=== - -[discrete] -=== indices.clone - -[source,ts] ----- -client.indices.clone({ - index: string, - target: string, - timeout: string, - master_timeout: string, - wait_for_active_shards: string, - body: object -}) ----- -link:{ref}/indices-clone-index.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the source index to clone - -|`target` -|`string` - The name of the target index to clone into - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Set the number of active shards to wait for on the cloned index before the operation returns. - -|`body` -|`object` - The configuration for the target index (`settings` and `aliases`) - -|=== - -[discrete] -=== indices.close - -[source,ts] ----- -client.indices.close({ - index: string | string[], - timeout: string, - master_timeout: string, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - wait_for_active_shards: string -}) ----- -link:{ref}/indices-open-close.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma separated list of indices to close - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of active shards to wait for before the operation returns. Set to `index-setting` to wait according to the index setting `index.write.wait_for_active_shards`, or `all` to wait for all shards, or an integer. Defaults to `0`. - -|=== - -[discrete] -=== indices.create - -[source,ts] ----- -client.indices.create({ - index: string, - include_type_name: boolean, - wait_for_active_shards: string, - timeout: string, - master_timeout: string, - body: object -}) ----- -link:{ref}/indices-create-index.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index - -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be expected in the body of the mappings. - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Set the number of active shards to wait for before the operation returns. - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`body` -|`object` - The configuration for the index (`settings` and `mappings`) - -|=== - -[discrete] -=== indices.createDataStream - -[source,ts] ----- -client.indices.createDataStream({ - name: string -}) ----- -link:{ref}/data-streams.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the data stream - -|=== - -[discrete] -=== indices.dataStreamsStats - -[source,ts] ----- -client.indices.dataStreamsStats({ - name: string | string[] -}) ----- -link:{ref}/data-streams.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of data stream names; use `_all` or empty string to perform the operation on all data streams - -|=== - -[discrete] -=== indices.delete - -[source,ts] ----- -client.indices.delete({ - index: string | string[], - timeout: string, - master_timeout: string, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/indices-delete-index.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Ignore unavailable indexes (default: false) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Ignore if a wildcard expression resolves to no concrete indices (default: false) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether wildcard expressions should get expanded to open or closed indices (default: open) + -_Default:_ `open` - -|=== - -[discrete] -=== indices.deleteAlias - -[source,ts] ----- -client.indices.deleteAlias({ - index: string | string[], - name: string | string[], - timeout: string, - master_timeout: string -}) ----- -link:{ref}/indices-aliases.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names (supports wildcards); use `_all` for all indices - -|`name` -|`string \| string[]` - A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices. - -|`timeout` -|`string` - Explicit timestamp for the document - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|=== - -[discrete] -=== indices.deleteDataStream - -[source,ts] ----- -client.indices.deleteDataStream({ - name: string | string[], - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/data-streams.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of data streams to delete; use `*` to delete all data streams - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether wildcard expressions should get expanded to open or closed indices (default: open) + -_Default:_ `open` - -|=== - -[discrete] -=== indices.deleteIndexTemplate - -[source,ts] ----- -client.indices.deleteIndexTemplate({ - name: string, - timeout: string, - master_timeout: string -}) ----- -link:{ref}/indices-templates.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the template - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|=== - -[discrete] -=== indices.deleteTemplate - -[source,ts] ----- -client.indices.deleteTemplate({ - name: string, - timeout: string, - master_timeout: string -}) ----- -link:{ref}/indices-templates.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the template - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|=== - -[discrete] -=== indices.diskUsage -*Stability:* experimental -[source,ts] ----- -client.indices.diskUsage({ - index: string, - run_expensive_tasks: boolean, - flush: boolean, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/indices-disk-usage.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - Comma-separated list of indices or data streams to analyze the disk usage - -|`run_expensive_tasks` or `runExpensiveTasks` -|`boolean` - Must be set to [true] in order for the task to be performed. Defaults to false. - -|`flush` -|`boolean` - Whether flush or not before analyzing the index disk usage. Defaults to true - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - -[discrete] -=== indices.exists - -[source,ts] ----- -client.indices.exists({ - index: string | string[], - local: boolean, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - flat_settings: boolean, - include_defaults: boolean -}) ----- -link:{ref}/indices-exists.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Ignore unavailable indexes (default: false) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Ignore if a wildcard expression resolves to no concrete indices (default: false) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether wildcard expressions should get expanded to open or closed indices (default: open) + -_Default:_ `open` - -|`flat_settings` or `flatSettings` -|`boolean` - Return settings in flat format (default: false) - -|`include_defaults` or `includeDefaults` -|`boolean` - Whether to return all default setting for each of the indices. - -|=== - -[discrete] -=== indices.existsAlias - -[source,ts] ----- -client.indices.existsAlias({ - name: string | string[], - index: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - local: boolean -}) ----- -link:{ref}/indices-aliases.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of alias names to return - -|`index` -|`string \| string[]` - A comma-separated list of index names to filter aliases - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `all` - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|=== - -[discrete] -=== indices.existsIndexTemplate - -[source,ts] ----- -client.indices.existsIndexTemplate({ - name: string, - flat_settings: boolean, - master_timeout: string, - local: boolean -}) ----- -link:{ref}/indices-templates.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the template - -|`flat_settings` or `flatSettings` -|`boolean` - Return settings in flat format (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|=== - -[discrete] -=== indices.existsTemplate - -[source,ts] ----- -client.indices.existsTemplate({ - name: string | string[], - flat_settings: boolean, - master_timeout: string, - local: boolean -}) ----- -link:{ref}/indices-templates.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - The comma separated names of the index templates - -|`flat_settings` or `flatSettings` -|`boolean` - Return settings in flat format (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|=== - -[discrete] -=== indices.existsType - -[source,ts] ----- -client.indices.existsType({ - index: string | string[], - type: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - local: boolean -}) ----- -link:{ref}/indices-types-exists.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` to check the types across all indices - -|`type` -|`string \| string[]` - A comma-separated list of document types to check - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|=== - -[discrete] -=== indices.fieldUsageStats -*Stability:* experimental -[source,ts] ----- -client.indices.fieldUsageStats({ - index: string, - fields: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/field-usage-stats.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - -|`fields` -|`string \| string[]` - A comma-separated list of fields to include in the stats if only a subset of fields should be returned (supports wildcards) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - -[discrete] -=== indices.flush - -[source,ts] ----- -client.indices.flush({ - index: string | string[], - force: boolean, - wait_if_ongoing: boolean, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/indices-flush.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string for all indices - -|`force` -|`boolean` - Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if no uncommitted changes are present. (This setting can be considered as internal) - -|`wait_if_ongoing` or `waitIfOngoing` -|`boolean` - If set to true the flush operation will block until the flush can be executed if another flush operation is already executing. The default is true. If set to false the flush will be skipped iff if another flush operation is already running. - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - -[discrete] -=== indices.flushSynced - -[source,ts] ----- -client.indices.flushSynced({ - index: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'none' | 'all' -}) ----- -link:{ref}/indices-synced-flush-api.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string for all indices - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - -[discrete] -=== indices.forcemerge - -[source,ts] ----- -client.indices.forcemerge({ - index: string | string[], - flush: boolean, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - max_num_segments: number, - only_expunge_deletes: boolean -}) ----- -link:{ref}/indices-forcemerge.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - -|`flush` -|`boolean` - Specify whether the index should be flushed after performing the operation (default: true) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`max_num_segments` or `maxNumSegments` -|`number` - The number of segments the index should be merged into (default: dynamic) - -|`only_expunge_deletes` or `onlyExpungeDeletes` -|`boolean` - Specify whether the operation should only expunge deleted documents - -|=== - -[discrete] -=== indices.freeze - -[source,ts] ----- -client.indices.freeze({ - index: string, - timeout: string, - master_timeout: string, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - wait_for_active_shards: string -}) ----- -link:{ref}/freeze-index-api.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index to freeze - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `closed` - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of active shards to wait for before the operation returns. - -|=== - -[discrete] -=== indices.get - -[source,ts] ----- -client.indices.get({ - index: string | string[], - include_type_name: boolean, - local: boolean, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - flat_settings: boolean, - include_defaults: boolean, - master_timeout: string -}) ----- -link:{ref}/indices-get-index.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names - -|`include_type_name` or `includeTypeName` -|`boolean` - Whether to add the type name to the response (default: false) - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Ignore unavailable indexes (default: false) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Ignore if a wildcard expression resolves to no concrete indices (default: false) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether wildcard expressions should get expanded to open or closed indices (default: open) + -_Default:_ `open` - -|`flat_settings` or `flatSettings` -|`boolean` - Return settings in flat format (default: false) - -|`include_defaults` or `includeDefaults` -|`boolean` - Whether to return all default setting for each of the indices. - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|=== - -[discrete] -=== indices.getAlias - -[source,ts] ----- -client.indices.getAlias({ - name: string | string[], - index: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - local: boolean -}) ----- -link:{ref}/indices-aliases.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of alias names to return - -|`index` -|`string \| string[]` - A comma-separated list of index names to filter aliases - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `all` - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|=== - -[discrete] -=== indices.getDataStream - -[source,ts] ----- -client.indices.getDataStream({ - name: string | string[], - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/data-streams.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of data streams to get; use `*` to get all data streams - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether wildcard expressions should get expanded to open or closed indices (default: open) + -_Default:_ `open` - -|=== - -[discrete] -=== indices.getFieldMapping - -[source,ts] ----- -client.indices.getFieldMapping({ - fields: string | string[], - index: string | string[], - type: string | string[], - include_type_name: boolean, - include_defaults: boolean, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - local: boolean -}) ----- -link:{ref}/indices-get-field-mapping.html[Documentation] + -[cols=2*] -|=== -|`fields` -|`string \| string[]` - A comma-separated list of fields - -|`index` -|`string \| string[]` - A comma-separated list of index names - -|`type` -|`string \| string[]` - A comma-separated list of document types + - -WARNING: This parameter has been deprecated. - -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be returned in the body of the mappings. - -|`include_defaults` or `includeDefaults` -|`boolean` - Whether the default mapping values should be returned as well - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|=== - -[discrete] -=== indices.getIndexTemplate - -[source,ts] ----- -client.indices.getIndexTemplate({ - name: string | string[], - flat_settings: boolean, - master_timeout: string, - local: boolean -}) ----- -link:{ref}/indices-templates.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - The comma separated names of the index templates - -|`flat_settings` or `flatSettings` -|`boolean` - Return settings in flat format (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|=== - -[discrete] -=== indices.getMapping - -[source,ts] ----- -client.indices.getMapping({ - index: string | string[], - type: string | string[], - include_type_name: boolean, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - master_timeout: string, - local: boolean -}) ----- -link:{ref}/indices-get-mapping.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names - -|`type` -|`string \| string[]` - A comma-separated list of document types + - -WARNING: This parameter has been deprecated. - -|`include_type_name` or `includeTypeName` -|`boolean` - Whether to add the type name to the response (default: false) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) + - -WARNING: This parameter has been deprecated. - -|=== - -[discrete] -=== indices.getSettings - -[source,ts] ----- -client.indices.getSettings({ - index: string | string[], - name: string | string[], - master_timeout: string, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - flat_settings: boolean, - local: boolean, - include_defaults: boolean -}) ----- -link:{ref}/indices-get-settings.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - -|`name` -|`string \| string[]` - The name of the settings that should be included - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `all` - -|`flat_settings` or `flatSettings` -|`boolean` - Return settings in flat format (default: false) - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`include_defaults` or `includeDefaults` -|`boolean` - Whether to return all default setting for each of the indices. - -|=== - -[discrete] -=== indices.getTemplate - -[source,ts] ----- -client.indices.getTemplate({ - name: string | string[], - include_type_name: boolean, - flat_settings: boolean, - master_timeout: string, - local: boolean -}) ----- -link:{ref}/indices-templates.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - The comma separated names of the index templates - -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be returned in the body of the mappings. - -|`flat_settings` or `flatSettings` -|`boolean` - Return settings in flat format (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|=== - -[discrete] -=== indices.getUpgrade - -[source,ts] ----- -client.indices.getUpgrade({ - index: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/indices-upgrade.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - -[discrete] -=== indices.migrateToDataStream - -[source,ts] ----- -client.indices.migrateToDataStream({ - name: string -}) ----- -link:{ref}/data-streams.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the alias to migrate - -|=== - -[discrete] -=== indices.open - -[source,ts] ----- -client.indices.open({ - index: string | string[], - timeout: string, - master_timeout: string, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - wait_for_active_shards: string -}) ----- -link:{ref}/indices-open-close.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma separated list of indices to open - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `closed` - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of active shards to wait for before the operation returns. - -|=== - -[discrete] -=== indices.promoteDataStream - -[source,ts] ----- -client.indices.promoteDataStream({ - name: string -}) ----- -link:{ref}/data-streams.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the data stream - -|=== - -[discrete] -=== indices.putAlias - -[source,ts] ----- -client.indices.putAlias({ - index: string | string[], - name: string, - timeout: string, - master_timeout: string, - body: object -}) ----- -link:{ref}/indices-aliases.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the operation on all indices. - -|`name` -|`string` - The name of the alias to be created or updated - -|`timeout` -|`string` - Explicit timestamp for the document - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`body` -|`object` - The settings for the alias, such as `routing` or `filter` - -|=== - -[discrete] -=== indices.putIndexTemplate - -[source,ts] ----- -client.indices.putIndexTemplate({ - name: string, - create: boolean, - cause: string, - master_timeout: string, - body: object -}) ----- -link:{ref}/indices-templates.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the template - -|`create` -|`boolean` - Whether the index template should only be added if new or can also replace an existing one - -|`cause` -|`string` - User defined reason for creating/updating the index template - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`body` -|`object` - The template definition - -|=== - -[discrete] -=== indices.putMapping - -[source,ts] ----- -client.indices.putMapping({ - index: string | string[], - type: string, - include_type_name: boolean, - timeout: string, - master_timeout: string, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - write_index_only: boolean, - body: object -}) ----- -link:{ref}/indices-put-mapping.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. - -|`type` -|`string` - The name of the document type + - -WARNING: This parameter has been deprecated. - -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be expected in the body of the mappings. - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`write_index_only` or `writeIndexOnly` -|`boolean` - When true, applies mappings only to the write index of an alias or data stream - -|`body` -|`object` - The mapping definition - -|=== - -[discrete] -=== indices.putSettings - -[source,ts] ----- -client.indices.putSettings({ - index: string | string[], - master_timeout: string, - timeout: string, - preserve_existing: boolean, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - flat_settings: boolean, - body: object -}) ----- -link:{ref}/indices-update-settings.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`timeout` -|`string` - Explicit operation timeout - -|`preserve_existing` or `preserveExisting` -|`boolean` - Whether to update existing settings. If set to `true` existing settings on an index remain unchanged, the default is `false` - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`flat_settings` or `flatSettings` -|`boolean` - Return settings in flat format (default: false) - -|`body` -|`object` - The index settings to be updated - -|=== - -[discrete] -=== indices.putTemplate - -[source,ts] ----- -client.indices.putTemplate({ - name: string, - include_type_name: boolean, - order: number, - create: boolean, - master_timeout: string, - body: object -}) ----- -link:{ref}/indices-templates.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the template - -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be returned in the body of the mappings. - -|`order` -|`number` - The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) - -|`create` -|`boolean` - Whether the index template should only be added if new or can also replace an existing one - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`body` -|`object` - The template definition - -|=== - -[discrete] -=== indices.recovery - -[source,ts] ----- -client.indices.recovery({ - index: string | string[], - detailed: boolean, - active_only: boolean -}) ----- -link:{ref}/indices-recovery.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - -|`detailed` -|`boolean` - Whether to display detailed information about shard recovery - -|`active_only` or `activeOnly` -|`boolean` - Display only those recoveries that are currently on-going - -|=== - -[discrete] -=== indices.refresh - -[source,ts] ----- -client.indices.refresh({ - index: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/indices-refresh.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - -[discrete] -=== indices.reloadSearchAnalyzers - -[source,ts] ----- -client.indices.reloadSearchAnalyzers({ - index: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/indices-reload-analyzers.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to reload analyzers for - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - -[discrete] -=== indices.resolveIndex -*Stability:* experimental -[source,ts] ----- -client.indices.resolveIndex({ - name: string | string[], - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/indices-resolve-index-api.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of names or wildcard expressions - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether wildcard expressions should get expanded to open or closed indices (default: open) + -_Default:_ `open` - -|=== - -[discrete] -=== indices.rollover - -[source,ts] ----- -client.indices.rollover({ - alias: string, - new_index: string, - include_type_name: boolean, - timeout: string, - dry_run: boolean, - master_timeout: string, - wait_for_active_shards: string, - body: object -}) ----- -link:{ref}/indices-rollover-index.html[Documentation] + -[cols=2*] -|=== -|`alias` -|`string` - The name of the alias to rollover - -|`new_index` or `newIndex` -|`string` - The name of the rollover index - -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be included in the body of the mappings. - -|`timeout` -|`string` - Explicit operation timeout - -|`dry_run` or `dryRun` -|`boolean` - If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Set the number of active shards to wait for on the newly created rollover index before the operation returns. - -|`body` -|`object` - The conditions that needs to be met for executing rollover - -|=== - -[discrete] -=== indices.segments - -[source,ts] ----- -client.indices.segments({ - index: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - verbose: boolean -}) ----- -link:{ref}/indices-segments.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`verbose` -|`boolean` - Includes detailed memory usage by Lucene. - -|=== - -[discrete] -=== indices.shardStores - -[source,ts] ----- -client.indices.shardStores({ - index: string | string[], - status: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/indices-shards-stores.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - -|`status` -|`string \| string[]` - A comma-separated list of statuses used to filter on shards to get store information for - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - -[discrete] -=== indices.shrink - -[source,ts] ----- -client.indices.shrink({ - index: string, - target: string, - copy_settings: boolean, - timeout: string, - master_timeout: string, - wait_for_active_shards: string, - body: object -}) ----- -link:{ref}/indices-shrink-index.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the source index to shrink - -|`target` -|`string` - The name of the target index to shrink into - -|`copy_settings` or `copySettings` -|`boolean` - whether or not to copy settings from the source index (defaults to false) - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Set the number of active shards to wait for on the shrunken index before the operation returns. - -|`body` -|`object` - The configuration for the target index (`settings` and `aliases`) - -|=== - -[discrete] -=== indices.simulateIndexTemplate - -[source,ts] ----- -client.indices.simulateIndexTemplate({ - name: string, - create: boolean, - cause: string, - master_timeout: string, - body: object -}) ----- -link:{ref}/indices-templates.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the index (it must be a concrete index name) - -|`create` -|`boolean` - Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one - -|`cause` -|`string` - User defined reason for dry-run creating the new template for simulation purposes - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`body` -|`object` - New index template definition, which will be included in the simulation, as if it already exists in the system - -|=== - -[discrete] -=== indices.simulateTemplate - -[source,ts] ----- -client.indices.simulateTemplate({ - name: string, - create: boolean, - cause: string, - master_timeout: string, - body: object -}) ----- -link:{ref}/indices-templates.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the index template - -|`create` -|`boolean` - Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one - -|`cause` -|`string` - User defined reason for dry-run creating the new template for simulation purposes - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`body` -|`object` - New index template definition to be simulated, if no index template name is specified - -|=== - -[discrete] -=== indices.split - -[source,ts] ----- -client.indices.split({ - index: string, - target: string, - copy_settings: boolean, - timeout: string, - master_timeout: string, - wait_for_active_shards: string, - body: object -}) ----- -link:{ref}/indices-split-index.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the source index to split - -|`target` -|`string` - The name of the target index to split into - -|`copy_settings` or `copySettings` -|`boolean` - whether or not to copy settings from the source index (defaults to false) - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Set the number of active shards to wait for on the shrunken index before the operation returns. - -|`body` -|`object` - The configuration for the target index (`settings` and `aliases`) - -|=== - -[discrete] -=== indices.stats - -[source,ts] ----- -client.indices.stats({ - metric: string | string[], - index: string | string[], - completion_fields: string | string[], - fielddata_fields: string | string[], - fields: string | string[], - groups: string | string[], - level: 'cluster' | 'indices' | 'shards', - types: string | string[], - include_segment_file_sizes: boolean, - include_unloaded_segments: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - forbid_closed_indices: boolean -}) ----- -link:{ref}/indices-stats.html[Documentation] + -[cols=2*] -|=== -|`metric` -|`string \| string[]` - Limit the information returned the specific metrics. - -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - -|`completion_fields` or `completionFields` -|`string \| string[]` - A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) - -|`fielddata_fields` or `fielddataFields` -|`string \| string[]` - A comma-separated list of fields for `fielddata` index metric (supports wildcards) - -|`fields` -|`string \| string[]` - A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) - -|`groups` -|`string \| string[]` - A comma-separated list of search groups for `search` index metric - -|`level` -|`'cluster' \| 'indices' \| 'shards'` - Return stats aggregated at cluster, index or shard level + -_Default:_ `indices` - -|`types` -|`string \| string[]` - A comma-separated list of document types for the `indexing` index metric - -|`include_segment_file_sizes` or `includeSegmentFileSizes` -|`boolean` - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) - -|`include_unloaded_segments` or `includeUnloadedSegments` -|`boolean` - If set to true segment stats will include stats for segments that are not currently loaded into memory - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`forbid_closed_indices` or `forbidClosedIndices` -|`boolean` - If set to false stats will also collected from closed indices if explicitly specified or if expand_wildcards expands to closed indices + -_Default:_ `true` - -|=== - -[discrete] -=== indices.unfreeze - -[source,ts] ----- -client.indices.unfreeze({ - index: string, - timeout: string, - master_timeout: string, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - wait_for_active_shards: string -}) ----- -link:{ref}/unfreeze-index-api.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index to unfreeze - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `closed` - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of active shards to wait for before the operation returns. - -|=== - -[discrete] -=== indices.updateAliases - -[source,ts] ----- -client.indices.updateAliases({ - timeout: string, - master_timeout: string, - body: object -}) ----- -link:{ref}/indices-aliases.html[Documentation] + -[cols=2*] -|=== -|`timeout` -|`string` - Request timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`body` -|`object` - The definition of `actions` to perform - -|=== - -[discrete] -=== indices.upgrade - -[source,ts] ----- -client.indices.upgrade({ - index: string | string[], - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - ignore_unavailable: boolean, - wait_for_completion: boolean, - only_ancient_segments: boolean -}) ----- -link:{ref}/indices-upgrade.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Specify whether the request should block until the all segments are upgraded (default: false) - -|`only_ancient_segments` or `onlyAncientSegments` -|`boolean` - If true, only ancient (an older Lucene major release) segments will be upgraded - -|=== - -[discrete] -=== indices.validateQuery - -[source,ts] ----- -client.indices.validateQuery({ - index: string | string[], - type: string | string[], - explain: boolean, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - q: string, - analyzer: string, - analyze_wildcard: boolean, - default_operator: 'AND' | 'OR', - df: string, - lenient: boolean, - rewrite: boolean, - all_shards: boolean, - body: object -}) ----- -link:{ref}/search-validate.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices - -|`type` -|`string \| string[]` - A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types + - -WARNING: This parameter has been deprecated. - -|`explain` -|`boolean` - Return detailed information about the error - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`q` -|`string` - Query in the Lucene query string syntax - -|`analyzer` -|`string` - The analyzer to use for the query string - -|`analyze_wildcard` or `analyzeWildcard` -|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) - -|`default_operator` or `defaultOperator` -|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + -_Default:_ `OR` - -|`df` -|`string` - The field to use as default where no field prefix is given in the query string - -|`lenient` -|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - -|`rewrite` -|`boolean` - Provide a more detailed explanation showing the actual Lucene query that will be executed. - -|`all_shards` or `allShards` -|`boolean` - Execute validation on all shards instead of one random shard per index - -|`body` -|`object` - The query definition specified with the Query DSL - -|=== - -[discrete] -=== info - -[source,ts] ----- -client.info() ----- -link:{ref}/index.html[Documentation] + - - -[discrete] -=== ingest.deletePipeline - -[source,ts] ----- -client.ingest.deletePipeline({ - id: string, - master_timeout: string, - timeout: string -}) ----- -link:{ref}/delete-pipeline-api.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - Pipeline ID - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -[discrete] -=== ingest.geoIpStats - -[source,ts] ----- -client.ingest.geoIpStats() ----- -link:{ref}/geoip-stats-api.html[Documentation] + - - -[discrete] -=== ingest.getPipeline - -[source,ts] ----- -client.ingest.getPipeline({ - id: string, - summary: boolean, - master_timeout: string -}) ----- -link:{ref}/get-pipeline-api.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - Comma separated list of pipeline ids. Wildcards supported - -|`summary` -|`boolean` - Return pipelines without their definitions (default: false) - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|=== - -[discrete] -=== ingest.processorGrok - -[source,ts] ----- -client.ingest.processorGrok() ----- -link:{ref}/grok-processor.html#grok-processor-rest-get[Documentation] + - - -[discrete] -=== ingest.putPipeline - -[source,ts] ----- -client.ingest.putPipeline({ - id: string, - master_timeout: string, - timeout: string, - body: object -}) ----- -link:{ref}/put-pipeline-api.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - Pipeline ID - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|`body` -|`object` - The ingest definition - -|=== - -[discrete] -=== ingest.simulate - -[source,ts] ----- -client.ingest.simulate({ - id: string, - verbose: boolean, - body: object -}) ----- -link:{ref}/simulate-pipeline-api.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - Pipeline ID - -|`verbose` -|`boolean` - Verbose mode. Display data output for each processor in executed pipeline - -|`body` -|`object` - The simulate definition - -|=== - -[discrete] -=== license.delete - -[source,ts] ----- -client.license.delete() ----- -link:{ref}/delete-license.html[Documentation] + - - -[discrete] -=== license.get - -[source,ts] ----- -client.license.get({ - local: boolean, - accept_enterprise: boolean -}) ----- -link:{ref}/get-license.html[Documentation] + -[cols=2*] -|=== -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`accept_enterprise` or `acceptEnterprise` -|`boolean` - If the active license is an enterprise license, return type as 'enterprise' (default: false) - -|=== - -[discrete] -=== license.getBasicStatus - -[source,ts] ----- -client.license.getBasicStatus() ----- -link:{ref}/get-basic-status.html[Documentation] + - - -[discrete] -=== license.getTrialStatus - -[source,ts] ----- -client.license.getTrialStatus() ----- -link:{ref}/get-trial-status.html[Documentation] + - - -[discrete] -=== license.post - -[source,ts] ----- -client.license.post({ - acknowledge: boolean, - body: object -}) ----- -link:{ref}/update-license.html[Documentation] + -[cols=2*] -|=== -|`acknowledge` -|`boolean` - whether the user has acknowledged acknowledge messages (default: false) - -|`body` -|`object` - licenses to be installed - -|=== - -[discrete] -=== license.postStartBasic - -[source,ts] ----- -client.license.postStartBasic({ - acknowledge: boolean -}) ----- -link:{ref}/start-basic.html[Documentation] + -[cols=2*] -|=== -|`acknowledge` -|`boolean` - whether the user has acknowledged acknowledge messages (default: false) - -|=== - -[discrete] -=== license.postStartTrial - -[source,ts] ----- -client.license.postStartTrial({ - type: string, - acknowledge: boolean -}) ----- -link:{ref}/start-trial.html[Documentation] + -[cols=2*] -|=== -|`type` -|`string` - The type of trial license to generate (default: "trial") - -|`acknowledge` -|`boolean` - whether the user has acknowledged acknowledge messages (default: false) - -|=== - -[discrete] -=== logstash.deletePipeline - -[source,ts] ----- -client.logstash.deletePipeline({ - id: string -}) ----- -link:{ref}/logstash-api-delete-pipeline.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the Pipeline - -|=== - -[discrete] -=== logstash.getPipeline - -[source,ts] ----- -client.logstash.getPipeline({ - id: string -}) ----- -link:{ref}/logstash-api-get-pipeline.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - A comma-separated list of Pipeline IDs - -|=== - -[discrete] -=== logstash.putPipeline - -[source,ts] ----- -client.logstash.putPipeline({ - id: string, - body: object -}) ----- -link:{ref}/logstash-api-put-pipeline.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the Pipeline - -|`body` -|`object` - The Pipeline to add or update - -|=== - -[discrete] -=== mget - -[source,ts] ----- -client.mget({ - index: string, - type: string, - stored_fields: string | string[], - preference: string, - realtime: boolean, - refresh: boolean, - routing: string, - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - body: object -}) ----- -link:{ref}/docs-multi-get.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index - -|`type` -|`string` - The type of the document + - -WARNING: This parameter has been deprecated. - -|`stored_fields` or `storedFields` -|`string \| string[]` - A comma-separated list of stored fields to return in the response - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`realtime` -|`boolean` - Specify whether to perform the operation in realtime or search mode - -|`refresh` -|`boolean` - Refresh the shard containing the document before performing the operation - -|`routing` -|`string` - Specific routing value - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`body` -|`object` - Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL. - -|=== - -[discrete] -=== migration.deprecations - -[source,ts] ----- -client.migration.deprecations({ - index: string -}) ----- -link:{ref}/migration-api-deprecation.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - Index pattern - -|=== - -[discrete] -=== ml.closeJob - -[source,ts] ----- -client.ml.closeJob({ - job_id: string, - allow_no_match: boolean, - allow_no_jobs: boolean, - force: boolean, - timeout: string, - body: object -}) ----- -link:{ref}/ml-close-job.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The name of the job to close - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) - -|`allow_no_jobs` or `allowNoJobs` -|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + - -WARNING: This parameter has been deprecated. - -|`force` -|`boolean` - True if the job should be forcefully closed - -|`timeout` -|`string` - Controls the time to wait until a job has closed. Default to 30 minutes - -|`body` -|`object` - The URL params optionally sent in the body - -|=== - -[discrete] -=== ml.deleteCalendar - -[source,ts] ----- -client.ml.deleteCalendar({ - calendar_id: string -}) ----- -link:{ref}/ml-delete-calendar.html[Documentation] + -[cols=2*] -|=== -|`calendar_id` or `calendarId` -|`string` - The ID of the calendar to delete - -|=== - -[discrete] -=== ml.deleteCalendarEvent - -[source,ts] ----- -client.ml.deleteCalendarEvent({ - calendar_id: string, - event_id: string -}) ----- -link:{ref}/ml-delete-calendar-event.html[Documentation] + -[cols=2*] -|=== -|`calendar_id` or `calendarId` -|`string` - The ID of the calendar to modify - -|`event_id` or `eventId` -|`string` - The ID of the event to remove from the calendar - -|=== - -[discrete] -=== ml.deleteCalendarJob - -[source,ts] ----- -client.ml.deleteCalendarJob({ - calendar_id: string, - job_id: string -}) ----- -link:{ref}/ml-delete-calendar-job.html[Documentation] + -[cols=2*] -|=== -|`calendar_id` or `calendarId` -|`string` - The ID of the calendar to modify - -|`job_id` or `jobId` -|`string` - The ID of the job to remove from the calendar - -|=== - -[discrete] -=== ml.deleteDataFrameAnalytics - -[source,ts] ----- -client.ml.deleteDataFrameAnalytics({ - id: string, - force: boolean, - timeout: string -}) ----- -link:{ref}/delete-dfanalytics.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the data frame analytics to delete - -|`force` -|`boolean` - True if the job should be forcefully deleted - -|`timeout` -|`string` - Controls the time to wait until a job is deleted. Defaults to 1 minute - -|=== - -[discrete] -=== ml.deleteDatafeed - -[source,ts] ----- -client.ml.deleteDatafeed({ - datafeed_id: string, - force: boolean -}) ----- -link:{ref}/ml-delete-datafeed.html[Documentation] + -[cols=2*] -|=== -|`datafeed_id` or `datafeedId` -|`string` - The ID of the datafeed to delete - -|`force` -|`boolean` - True if the datafeed should be forcefully deleted - -|=== - -[discrete] -=== ml.deleteExpiredData - -[source,ts] ----- -client.ml.deleteExpiredData({ - job_id: string, - requests_per_second: number, - timeout: string, - body: object -}) ----- -link:{ref}/ml-delete-expired-data.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the job(s) to perform expired data hygiene for - -|`requests_per_second` or `requestsPerSecond` -|`number` - The desired requests per second for the deletion processes. - -|`timeout` -|`string` - How long can the underlying delete processes run until they are canceled - -|`body` -|`object` - deleting expired data parameters - -|=== - -[discrete] -=== ml.deleteFilter - -[source,ts] ----- -client.ml.deleteFilter({ - filter_id: string -}) ----- -link:{ref}/ml-delete-filter.html[Documentation] + -[cols=2*] -|=== -|`filter_id` or `filterId` -|`string` - The ID of the filter to delete - -|=== - -[discrete] -=== ml.deleteForecast - -[source,ts] ----- -client.ml.deleteForecast({ - job_id: string, - forecast_id: string, - allow_no_forecasts: boolean, - timeout: string -}) ----- -link:{ref}/ml-delete-forecast.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the job from which to delete forecasts - -|`forecast_id` or `forecastId` -|`string` - The ID of the forecast to delete, can be comma delimited list. Leaving blank implies `_all` - -|`allow_no_forecasts` or `allowNoForecasts` -|`boolean` - Whether to ignore if `_all` matches no forecasts - -|`timeout` -|`string` - Controls the time to wait until the forecast(s) are deleted. Default to 30 seconds - -|=== - -[discrete] -=== ml.deleteJob - -[source,ts] ----- -client.ml.deleteJob({ - job_id: string, - force: boolean, - wait_for_completion: boolean -}) ----- -link:{ref}/ml-delete-job.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the job to delete - -|`force` -|`boolean` - True if the job should be forcefully deleted - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should this request wait until the operation has completed before returning + -_Default:_ `true` - -|=== - -[discrete] -=== ml.deleteModelSnapshot - -[source,ts] ----- -client.ml.deleteModelSnapshot({ - job_id: string, - snapshot_id: string -}) ----- -link:{ref}/ml-delete-snapshot.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the job to fetch - -|`snapshot_id` or `snapshotId` -|`string` - The ID of the snapshot to delete - -|=== - -[discrete] -=== ml.deleteTrainedModel - -[source,ts] ----- -client.ml.deleteTrainedModel({ - model_id: string -}) ----- -link:{ref}/delete-trained-models.html[Documentation] + -[cols=2*] -|=== -|`model_id` or `modelId` -|`string` - The ID of the trained model to delete - -|=== - -[discrete] -=== ml.deleteTrainedModelAlias - -[source,ts] ----- -client.ml.deleteTrainedModelAlias({ - model_alias: string, - model_id: string -}) ----- -link:{ref}/delete-trained-models-aliases.html[Documentation] + -[cols=2*] -|=== -|`model_alias` or `modelAlias` -|`string` - The trained model alias to delete - -|`model_id` or `modelId` -|`string` - The trained model where the model alias is assigned - -|=== - -[discrete] -=== ml.estimateModelMemory - -[source,ts] ----- -client.ml.estimateModelMemory({ - body: object -}) ----- -link:{ref}/ml-apis.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - The analysis config, plus cardinality estimates for fields it references - -|=== - -[discrete] -=== ml.evaluateDataFrame - -[source,ts] ----- -client.ml.evaluateDataFrame({ - body: object -}) ----- -link:{ref}/evaluate-dfanalytics.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - The evaluation definition - -|=== - -[discrete] -=== ml.explainDataFrameAnalytics - -[source,ts] ----- -client.ml.explainDataFrameAnalytics({ - id: string, - body: object -}) ----- -link:{ref}/explain-dfanalytics.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the data frame analytics to explain - -|`body` -|`object` - The data frame analytics config to explain - -|=== - -[discrete] -=== ml.findFileStructure -*Stability:* experimental -[source,ts] ----- -client.ml.findFileStructure({ - lines_to_sample: number, - line_merge_size_limit: number, - timeout: string, - charset: string, - format: 'ndjson' | 'xml' | 'delimited' | 'semi_structured_text', - has_header_row: boolean, - column_names: string | string[], - delimiter: string, - quote: string, - should_trim_fields: boolean, - grok_pattern: string, - timestamp_field: string, - timestamp_format: string, - explain: boolean, - body: object -}) ----- -link:{ref}/find-structure.html[Documentation] + -[cols=2*] -|=== -|`lines_to_sample` or `linesToSample` -|`number` - How many lines of the file should be included in the analysis + -_Default:_ `1000` - -|`line_merge_size_limit` or `lineMergeSizeLimit` -|`number` - Maximum number of characters permitted in a single message when lines are merged to create messages. + -_Default:_ `10000` - -|`timeout` -|`string` - Timeout after which the analysis will be aborted + -_Default:_ `25s` - -|`charset` -|`string` - Optional parameter to specify the character set of the file - -|`format` -|`'ndjson' \| 'xml' \| 'delimited' \| 'semi_structured_text'` - Optional parameter to specify the high level file format - -|`has_header_row` or `hasHeaderRow` -|`boolean` - Optional parameter to specify whether a delimited file includes the column names in its first row - -|`column_names` or `columnNames` -|`string \| string[]` - Optional parameter containing a comma separated list of the column names for a delimited file - -|`delimiter` -|`string` - Optional parameter to specify the delimiter character for a delimited file - must be a single character - -|`quote` -|`string` - Optional parameter to specify the quote character for a delimited file - must be a single character - -|`should_trim_fields` or `shouldTrimFields` -|`boolean` - Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them - -|`grok_pattern` or `grokPattern` -|`string` - Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file - -|`timestamp_field` or `timestampField` -|`string` - Optional parameter to specify the timestamp field in the file - -|`timestamp_format` or `timestampFormat` -|`string` - Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format - -|`explain` -|`boolean` - Whether to include a commentary on how the structure was derived - -|`body` -|`object` - The contents of the file to be analyzed - -|=== - -[discrete] -=== ml.flushJob - -[source,ts] ----- -client.ml.flushJob({ - job_id: string, - calc_interim: boolean, - start: string, - end: string, - advance_time: string, - skip_time: string, - body: object -}) ----- -link:{ref}/ml-flush-job.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The name of the job to flush - -|`calc_interim` or `calcInterim` -|`boolean` - Calculates interim results for the most recent bucket or all buckets within the latency period - -|`start` -|`string` - When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results - -|`end` -|`string` - When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results - -|`advance_time` or `advanceTime` -|`string` - Advances time to the given value generating results and updating the model for the advanced interval - -|`skip_time` or `skipTime` -|`string` - Skips time to the given value without generating results or updating the model for the skipped interval - -|`body` -|`object` - Flush parameters - -|=== - -[discrete] -=== ml.forecast - -[source,ts] ----- -client.ml.forecast({ - job_id: string, - duration: string, - expires_in: string, - max_model_memory: string -}) ----- -link:{ref}/ml-forecast.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the job to forecast for - -|`duration` -|`string` - The duration of the forecast - -|`expires_in` or `expiresIn` -|`string` - The time interval after which the forecast expires. Expired forecasts will be deleted at the first opportunity. - -|`max_model_memory` or `maxModelMemory` -|`string` - The max memory able to be used by the forecast. Default is 20mb. - -|=== - -[discrete] -=== ml.getBuckets - -[source,ts] ----- -client.ml.getBuckets({ - job_id: string, - timestamp: string, - expand: boolean, - exclude_interim: boolean, - from: number, - size: number, - start: string, - end: string, - anomaly_score: number, - sort: string, - desc: boolean, - body: object -}) ----- -link:{ref}/ml-get-bucket.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - ID of the job to get bucket results from - -|`timestamp` -|`string` - The timestamp of the desired single bucket result - -|`expand` -|`boolean` - Include anomaly records - -|`exclude_interim` or `excludeInterim` -|`boolean` - Exclude interim results - -|`from` -|`number` - skips a number of buckets - -|`size` -|`number` - specifies a max number of buckets to get - -|`start` -|`string` - Start time filter for buckets - -|`end` -|`string` - End time filter for buckets - -|`anomaly_score` or `anomalyScore` -|`number` - Filter for the most anomalous buckets - -|`sort` -|`string` - Sort buckets by a particular field - -|`desc` -|`boolean` - Set the sort direction - -|`body` -|`object` - Bucket selection details if not provided in URI - -|=== - -[discrete] -=== ml.getCalendarEvents - -[source,ts] ----- -client.ml.getCalendarEvents({ - calendar_id: string, - job_id: string, - start: string, - end: string, - from: number, - size: number -}) ----- -link:{ref}/ml-get-calendar-event.html[Documentation] + -[cols=2*] -|=== -|`calendar_id` or `calendarId` -|`string` - The ID of the calendar containing the events - -|`job_id` or `jobId` -|`string` - Get events for the job. When this option is used calendar_id must be '_all' - -|`start` -|`string` - Get events after this time - -|`end` -|`string` - Get events before this time - -|`from` -|`number` - Skips a number of events - -|`size` -|`number` - Specifies a max number of events to get - -|=== - -[discrete] -=== ml.getCalendars - -[source,ts] ----- -client.ml.getCalendars({ - calendar_id: string, - from: number, - size: number, - body: object -}) ----- -link:{ref}/ml-get-calendar.html[Documentation] + -[cols=2*] -|=== -|`calendar_id` or `calendarId` -|`string` - The ID of the calendar to fetch - -|`from` -|`number` - skips a number of calendars - -|`size` -|`number` - specifies a max number of calendars to get - -|`body` -|`object` - The from and size parameters optionally sent in the body - -|=== - -[discrete] -=== ml.getCategories - -[source,ts] ----- -client.ml.getCategories({ - job_id: string, - category_id: number, - from: number, - size: number, - partition_field_value: string, - body: object -}) ----- -link:{ref}/ml-get-category.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The name of the job - -|`category_id` or `categoryId` -|`number` - The identifier of the category definition of interest - -|`from` -|`number` - skips a number of categories - -|`size` -|`number` - specifies a max number of categories to get - -|`partition_field_value` or `partitionFieldValue` -|`string` - Specifies the partition to retrieve categories for. This is optional, and should never be used for jobs where per-partition categorization is disabled. - -|`body` -|`object` - Category selection details if not provided in URI - -|=== - -[discrete] -=== ml.getDataFrameAnalytics - -[source,ts] ----- -client.ml.getDataFrameAnalytics({ - id: string, - allow_no_match: boolean, - from: number, - size: number, - exclude_generated: boolean -}) ----- -link:{ref}/get-dfanalytics.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the data frame analytics to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no data frame analytics. (This includes `_all` string or when no data frame analytics have been specified) + -_Default:_ `true` - -|`from` -|`number` - skips a number of analytics - -|`size` -|`number` - specifies a max number of analytics to get + -_Default:_ `100` - -|`exclude_generated` or `excludeGenerated` -|`boolean` - Omits fields that are illegal to set on data frame analytics PUT - -|=== - -[discrete] -=== ml.getDataFrameAnalyticsStats - -[source,ts] ----- -client.ml.getDataFrameAnalyticsStats({ - id: string, - allow_no_match: boolean, - from: number, - size: number, - verbose: boolean -}) ----- -link:{ref}/get-dfanalytics-stats.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the data frame analytics stats to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no data frame analytics. (This includes `_all` string or when no data frame analytics have been specified) + -_Default:_ `true` - -|`from` -|`number` - skips a number of analytics - -|`size` -|`number` - specifies a max number of analytics to get + -_Default:_ `100` - -|`verbose` -|`boolean` - whether the stats response should be verbose - -|=== - -[discrete] -=== ml.getDatafeedStats - -[source,ts] ----- -client.ml.getDatafeedStats({ - datafeed_id: string, - allow_no_match: boolean, - allow_no_datafeeds: boolean -}) ----- -link:{ref}/ml-get-datafeed-stats.html[Documentation] + -[cols=2*] -|=== -|`datafeed_id` or `datafeedId` -|`string` - The ID of the datafeeds stats to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) - -|`allow_no_datafeeds` or `allowNoDatafeeds` -|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + - -WARNING: This parameter has been deprecated. - -|=== - -[discrete] -=== ml.getDatafeeds - -[source,ts] ----- -client.ml.getDatafeeds({ - datafeed_id: string, - allow_no_match: boolean, - allow_no_datafeeds: boolean, - exclude_generated: boolean -}) ----- -link:{ref}/ml-get-datafeed.html[Documentation] + -[cols=2*] -|=== -|`datafeed_id` or `datafeedId` -|`string` - The ID of the datafeeds to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) - -|`allow_no_datafeeds` or `allowNoDatafeeds` -|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + - -WARNING: This parameter has been deprecated. - -|`exclude_generated` or `excludeGenerated` -|`boolean` - Omits fields that are illegal to set on datafeed PUT - -|=== - -[discrete] -=== ml.getFilters - -[source,ts] ----- -client.ml.getFilters({ - filter_id: string, - from: number, - size: number -}) ----- -link:{ref}/ml-get-filter.html[Documentation] + -[cols=2*] -|=== -|`filter_id` or `filterId` -|`string` - The ID of the filter to fetch - -|`from` -|`number` - skips a number of filters - -|`size` -|`number` - specifies a max number of filters to get - -|=== - -[discrete] -=== ml.getInfluencers - -[source,ts] ----- -client.ml.getInfluencers({ - job_id: string, - exclude_interim: boolean, - from: number, - size: number, - start: string, - end: string, - influencer_score: number, - sort: string, - desc: boolean, - body: object -}) ----- -link:{ref}/ml-get-influencer.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - Identifier for the anomaly detection job - -|`exclude_interim` or `excludeInterim` -|`boolean` - Exclude interim results - -|`from` -|`number` - skips a number of influencers - -|`size` -|`number` - specifies a max number of influencers to get - -|`start` -|`string` - start timestamp for the requested influencers - -|`end` -|`string` - end timestamp for the requested influencers - -|`influencer_score` or `influencerScore` -|`number` - influencer score threshold for the requested influencers - -|`sort` -|`string` - sort field for the requested influencers - -|`desc` -|`boolean` - whether the results should be sorted in decending order - -|`body` -|`object` - Influencer selection criteria - -|=== - -[discrete] -=== ml.getJobStats - -[source,ts] ----- -client.ml.getJobStats({ - job_id: string, - allow_no_match: boolean, - allow_no_jobs: boolean -}) ----- -link:{ref}/ml-get-job-stats.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the jobs stats to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) - -|`allow_no_jobs` or `allowNoJobs` -|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + - -WARNING: This parameter has been deprecated. - -|=== - -[discrete] -=== ml.getJobs - -[source,ts] ----- -client.ml.getJobs({ - job_id: string, - allow_no_match: boolean, - allow_no_jobs: boolean, - exclude_generated: boolean -}) ----- -link:{ref}/ml-get-job.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the jobs to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) - -|`allow_no_jobs` or `allowNoJobs` -|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + - -WARNING: This parameter has been deprecated. - -|`exclude_generated` or `excludeGenerated` -|`boolean` - Omits fields that are illegal to set on job PUT - -|=== - -[discrete] -=== ml.getModelSnapshots - -[source,ts] ----- -client.ml.getModelSnapshots({ - job_id: string, - snapshot_id: string, - from: number, - size: number, - start: string, - end: string, - sort: string, - desc: boolean, - body: object -}) ----- -link:{ref}/ml-get-snapshot.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the job to fetch - -|`snapshot_id` or `snapshotId` -|`string` - The ID of the snapshot to fetch - -|`from` -|`number` - Skips a number of documents - -|`size` -|`number` - The default number of documents returned in queries as a string. - -|`start` -|`string` - The filter 'start' query parameter - -|`end` -|`string` - The filter 'end' query parameter - -|`sort` -|`string` - Name of the field to sort on - -|`desc` -|`boolean` - True if the results should be sorted in descending order - -|`body` -|`object` - Model snapshot selection criteria - -|=== - -[discrete] -=== ml.getOverallBuckets - -[source,ts] ----- -client.ml.getOverallBuckets({ - job_id: string, - top_n: number, - bucket_span: string, - overall_score: number, - exclude_interim: boolean, - start: string, - end: string, - allow_no_match: boolean, - allow_no_jobs: boolean, - body: object -}) ----- -link:{ref}/ml-get-overall-buckets.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The job IDs for which to calculate overall bucket results - -|`top_n` or `topN` -|`number` - The number of top job bucket scores to be used in the overall_score calculation - -|`bucket_span` or `bucketSpan` -|`string` - The span of the overall buckets. Defaults to the longest job bucket_span - -|`overall_score` or `overallScore` -|`number` - Returns overall buckets with overall scores higher than this value - -|`exclude_interim` or `excludeInterim` -|`boolean` - If true overall buckets that include interim buckets will be excluded - -|`start` -|`string` - Returns overall buckets with timestamps after this time - -|`end` -|`string` - Returns overall buckets with timestamps earlier than this time - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) - -|`allow_no_jobs` or `allowNoJobs` -|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + - -WARNING: This parameter has been deprecated. - -|`body` -|`object` - Overall bucket selection details if not provided in URI - -|=== - -[discrete] -=== ml.getRecords - -[source,ts] ----- -client.ml.getRecords({ - job_id: string, - exclude_interim: boolean, - from: number, - size: number, - start: string, - end: string, - record_score: number, - sort: string, - desc: boolean, - body: object -}) ----- -link:{ref}/ml-get-record.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the job - -|`exclude_interim` or `excludeInterim` -|`boolean` - Exclude interim results - -|`from` -|`number` - skips a number of records - -|`size` -|`number` - specifies a max number of records to get - -|`start` -|`string` - Start time filter for records - -|`end` -|`string` - End time filter for records - -|`record_score` or `recordScore` -|`number` - Returns records with anomaly scores greater or equal than this value - -|`sort` -|`string` - Sort records by a particular field - -|`desc` -|`boolean` - Set the sort direction - -|`body` -|`object` - Record selection criteria - -|=== - -[discrete] -=== ml.getTrainedModels - -[source,ts] ----- -client.ml.getTrainedModels({ - model_id: string, - allow_no_match: boolean, - include: string, - include_model_definition: boolean, - decompress_definition: boolean, - from: number, - size: number, - tags: string | string[], - exclude_generated: boolean -}) ----- -link:{ref}/get-trained-models.html[Documentation] + -[cols=2*] -|=== -|`model_id` or `modelId` -|`string` - The ID of the trained models to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) + -_Default:_ `true` - -|`include` -|`string` - A comma-separate list of fields to optionally include. Valid options are 'definition' and 'total_feature_importance'. Default is none. - -|`include_model_definition` or `includeModelDefinition` -|`boolean` - Should the full model definition be included in the results. These definitions can be large. So be cautious when including them. Defaults to false. + - -WARNING: This parameter has been deprecated. - -|`decompress_definition` or `decompressDefinition` -|`boolean` - Should the model definition be decompressed into valid JSON or returned in a custom compressed format. Defaults to true. + -_Default:_ `true` - -|`from` -|`number` - skips a number of trained models - -|`size` -|`number` - specifies a max number of trained models to get + -_Default:_ `100` - -|`tags` -|`string \| string[]` - A comma-separated list of tags that the model must have. - -|`exclude_generated` or `excludeGenerated` -|`boolean` - Omits fields that are illegal to set on model PUT - -|=== - -[discrete] -=== ml.getTrainedModelsStats - -[source,ts] ----- -client.ml.getTrainedModelsStats({ - model_id: string, - allow_no_match: boolean, - from: number, - size: number -}) ----- -link:{ref}/get-trained-models-stats.html[Documentation] + -[cols=2*] -|=== -|`model_id` or `modelId` -|`string` - The ID of the trained models stats to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) + -_Default:_ `true` - -|`from` -|`number` - skips a number of trained models - -|`size` -|`number` - specifies a max number of trained models to get + -_Default:_ `100` - -|=== - -[discrete] -=== ml.info - -[source,ts] ----- -client.ml.info() ----- -link:{ref}/get-ml-info.html[Documentation] + - - -[discrete] -=== ml.openJob - -[source,ts] ----- -client.ml.openJob({ - job_id: string -}) ----- -link:{ref}/ml-open-job.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the job to open - -|=== - -[discrete] -=== ml.postCalendarEvents - -[source,ts] ----- -client.ml.postCalendarEvents({ - calendar_id: string, - body: object -}) ----- -link:{ref}/ml-post-calendar-event.html[Documentation] + -[cols=2*] -|=== -|`calendar_id` or `calendarId` -|`string` - The ID of the calendar to modify - -|`body` -|`object` - A list of events - -|=== - -[discrete] -=== ml.postData - -[source,ts] ----- -client.ml.postData({ - job_id: string, - reset_start: string, - reset_end: string, - body: object -}) ----- -link:{ref}/ml-post-data.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The name of the job receiving the data - -|`reset_start` or `resetStart` -|`string` - Optional parameter to specify the start of the bucket resetting range - -|`reset_end` or `resetEnd` -|`string` - Optional parameter to specify the end of the bucket resetting range - -|`body` -|`object` - The data to process - -|=== - -[discrete] -=== ml.previewDataFrameAnalytics - -[source,ts] ----- -client.ml.previewDataFrameAnalytics({ - id: string, - body: object -}) ----- -link:{ref}/preview-dfanalytics.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the data frame analytics to preview - -|`body` -|`object` - The data frame analytics config to preview - -|=== - -[discrete] -=== ml.previewDatafeed - -[source,ts] ----- -client.ml.previewDatafeed({ - datafeed_id: string, - body: object -}) ----- -link:{ref}/ml-preview-datafeed.html[Documentation] + -[cols=2*] -|=== -|`datafeed_id` or `datafeedId` -|`string` - The ID of the datafeed to preview - -|`body` -|`object` - The datafeed config and job config with which to execute the preview - -|=== - -[discrete] -=== ml.putCalendar - -[source,ts] ----- -client.ml.putCalendar({ - calendar_id: string, - body: object -}) ----- -link:{ref}/ml-put-calendar.html[Documentation] + -[cols=2*] -|=== -|`calendar_id` or `calendarId` -|`string` - The ID of the calendar to create - -|`body` -|`object` - The calendar details - -|=== - -[discrete] -=== ml.putCalendarJob - -[source,ts] ----- -client.ml.putCalendarJob({ - calendar_id: string, - job_id: string -}) ----- -link:{ref}/ml-put-calendar-job.html[Documentation] + -[cols=2*] -|=== -|`calendar_id` or `calendarId` -|`string` - The ID of the calendar to modify - -|`job_id` or `jobId` -|`string` - The ID of the job to add to the calendar - -|=== - -[discrete] -=== ml.putDataFrameAnalytics - -[source,ts] ----- -client.ml.putDataFrameAnalytics({ - id: string, - body: object -}) ----- -link:{ref}/put-dfanalytics.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the data frame analytics to create - -|`body` -|`object` - The data frame analytics configuration - -|=== - -[discrete] -=== ml.putDatafeed - -[source,ts] ----- -client.ml.putDatafeed({ - datafeed_id: string, - ignore_unavailable: boolean, - allow_no_indices: boolean, - ignore_throttled: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - body: object -}) ----- -link:{ref}/ml-put-datafeed.html[Documentation] + -[cols=2*] -|=== -|`datafeed_id` or `datafeedId` -|`string` - The ID of the datafeed to create - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Ignore unavailable indexes (default: false) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Ignore if the source indices expressions resolves to no concrete indices (default: true) - -|`ignore_throttled` or `ignoreThrottled` -|`boolean` - Ignore indices that are marked as throttled (default: true) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether source index expressions should get expanded to open or closed indices (default: open) - -|`body` -|`object` - The datafeed config - -|=== - -[discrete] -=== ml.putFilter - -[source,ts] ----- -client.ml.putFilter({ - filter_id: string, - body: object -}) ----- -link:{ref}/ml-put-filter.html[Documentation] + -[cols=2*] -|=== -|`filter_id` or `filterId` -|`string` - The ID of the filter to create - -|`body` -|`object` - The filter details - -|=== - -[discrete] -=== ml.putJob - -[source,ts] ----- -client.ml.putJob({ - job_id: string, - ignore_unavailable: boolean, - allow_no_indices: boolean, - ignore_throttled: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - body: object -}) ----- -link:{ref}/ml-put-job.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the job to create - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Ignore unavailable indexes (default: false). Only set if datafeed_config is provided. - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Ignore if the source indices expressions resolves to no concrete indices (default: true). Only set if datafeed_config is provided. - -|`ignore_throttled` or `ignoreThrottled` -|`boolean` - Ignore indices that are marked as throttled (default: true). Only set if datafeed_config is provided. - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether source index expressions should get expanded to open or closed indices (default: open). Only set if datafeed_config is provided. - -|`body` -|`object` - The job - -|=== - -[discrete] -=== ml.putTrainedModel - -[source,ts] ----- -client.ml.putTrainedModel({ - model_id: string, - body: object -}) ----- -link:{ref}/put-trained-models.html[Documentation] + -[cols=2*] -|=== -|`model_id` or `modelId` -|`string` - The ID of the trained models to store - -|`body` -|`object` - The trained model configuration - -|=== - -[discrete] -=== ml.putTrainedModelAlias - -[source,ts] ----- -client.ml.putTrainedModelAlias({ - model_alias: string, - model_id: string, - reassign: boolean -}) ----- -link:{ref}/put-trained-models-aliases.html[Documentation] + -[cols=2*] -|=== -|`model_alias` or `modelAlias` -|`string` - The trained model alias to update - -|`model_id` or `modelId` -|`string` - The trained model where the model alias should be assigned - -|`reassign` -|`boolean` - If the model_alias already exists and points to a separate model_id, this parameter must be true. Defaults to false. - -|=== - -[discrete] -=== ml.resetJob - -[source,ts] ----- -client.ml.resetJob({ - job_id: string, - wait_for_completion: boolean -}) ----- -link:{ref}/ml-reset-job.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the job to reset - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should this request wait until the operation has completed before returning + -_Default:_ `true` - -|=== - -[discrete] -=== ml.revertModelSnapshot - -[source,ts] ----- -client.ml.revertModelSnapshot({ - job_id: string, - snapshot_id: string, - delete_intervening_results: boolean, - body: object -}) ----- -link:{ref}/ml-revert-snapshot.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the job to fetch - -|`snapshot_id` or `snapshotId` -|`string` - The ID of the snapshot to revert to - -|`delete_intervening_results` or `deleteInterveningResults` -|`boolean` - Should we reset the results back to the time of the snapshot? - -|`body` -|`object` - Reversion options - -|=== - -[discrete] -=== ml.setUpgradeMode - -[source,ts] ----- -client.ml.setUpgradeMode({ - enabled: boolean, - timeout: string -}) ----- -link:{ref}/ml-set-upgrade-mode.html[Documentation] + -[cols=2*] -|=== -|`enabled` -|`boolean` - Whether to enable upgrade_mode ML setting or not. Defaults to false. - -|`timeout` -|`string` - Controls the time to wait before action times out. Defaults to 30 seconds - -|=== - -[discrete] -=== ml.startDataFrameAnalytics - -[source,ts] ----- -client.ml.startDataFrameAnalytics({ - id: string, - timeout: string, - body: object -}) ----- -link:{ref}/start-dfanalytics.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the data frame analytics to start - -|`timeout` -|`string` - Controls the time to wait until the task has started. Defaults to 20 seconds - -|`body` -|`object` - The start data frame analytics parameters - -|=== - -[discrete] -=== ml.startDatafeed - -[source,ts] ----- -client.ml.startDatafeed({ - datafeed_id: string, - start: string, - end: string, - timeout: string, - body: object -}) ----- -link:{ref}/ml-start-datafeed.html[Documentation] + -[cols=2*] -|=== -|`datafeed_id` or `datafeedId` -|`string` - The ID of the datafeed to start - -|`start` -|`string` - The start time from where the datafeed should begin - -|`end` -|`string` - The end time when the datafeed should stop. When not set, the datafeed continues in real time - -|`timeout` -|`string` - Controls the time to wait until a datafeed has started. Default to 20 seconds - -|`body` -|`object` - The start datafeed parameters - -|=== - -[discrete] -=== ml.stopDataFrameAnalytics - -[source,ts] ----- -client.ml.stopDataFrameAnalytics({ - id: string, - allow_no_match: boolean, - force: boolean, - timeout: string, - body: object -}) ----- -link:{ref}/stop-dfanalytics.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the data frame analytics to stop - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no data frame analytics. (This includes `_all` string or when no data frame analytics have been specified) - -|`force` -|`boolean` - True if the data frame analytics should be forcefully stopped - -|`timeout` -|`string` - Controls the time to wait until the task has stopped. Defaults to 20 seconds - -|`body` -|`object` - The stop data frame analytics parameters - -|=== - -[discrete] -=== ml.stopDatafeed - -[source,ts] ----- -client.ml.stopDatafeed({ - datafeed_id: string, - allow_no_match: boolean, - allow_no_datafeeds: boolean, - force: boolean, - timeout: string, - body: object -}) ----- -link:{ref}/ml-stop-datafeed.html[Documentation] + -[cols=2*] -|=== -|`datafeed_id` or `datafeedId` -|`string` - The ID of the datafeed to stop - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) - -|`allow_no_datafeeds` or `allowNoDatafeeds` -|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + - -WARNING: This parameter has been deprecated. - -|`force` -|`boolean` - True if the datafeed should be forcefully stopped. - -|`timeout` -|`string` - Controls the time to wait until a datafeed has stopped. Default to 20 seconds - -|`body` -|`object` - The URL params optionally sent in the body - -|=== - -[discrete] -=== ml.updateDataFrameAnalytics - -[source,ts] ----- -client.ml.updateDataFrameAnalytics({ - id: string, - body: object -}) ----- -link:{ref}/update-dfanalytics.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the data frame analytics to update - -|`body` -|`object` - The data frame analytics settings to update - -|=== - -[discrete] -=== ml.updateDatafeed - -[source,ts] ----- -client.ml.updateDatafeed({ - datafeed_id: string, - ignore_unavailable: boolean, - allow_no_indices: boolean, - ignore_throttled: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - body: object -}) ----- -link:{ref}/ml-update-datafeed.html[Documentation] + -[cols=2*] -|=== -|`datafeed_id` or `datafeedId` -|`string` - The ID of the datafeed to update - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Ignore unavailable indexes (default: false) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Ignore if the source indices expressions resolves to no concrete indices (default: true) - -|`ignore_throttled` or `ignoreThrottled` -|`boolean` - Ignore indices that are marked as throttled (default: true) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether source index expressions should get expanded to open or closed indices (default: open) - -|`body` -|`object` - The datafeed update settings - -|=== - -[discrete] -=== ml.updateFilter - -[source,ts] ----- -client.ml.updateFilter({ - filter_id: string, - body: object -}) ----- -link:{ref}/ml-update-filter.html[Documentation] + -[cols=2*] -|=== -|`filter_id` or `filterId` -|`string` - The ID of the filter to update - -|`body` -|`object` - The filter update - -|=== - -[discrete] -=== ml.updateJob - -[source,ts] ----- -client.ml.updateJob({ - job_id: string, - body: object -}) ----- -link:{ref}/ml-update-job.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the job to create - -|`body` -|`object` - The job update settings - -|=== - -[discrete] -=== ml.updateModelSnapshot - -[source,ts] ----- -client.ml.updateModelSnapshot({ - job_id: string, - snapshot_id: string, - body: object -}) ----- -link:{ref}/ml-update-snapshot.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the job to fetch - -|`snapshot_id` or `snapshotId` -|`string` - The ID of the snapshot to update - -|`body` -|`object` - The model snapshot properties to update - -|=== - -[discrete] -=== ml.upgradeJobSnapshot - -[source,ts] ----- -client.ml.upgradeJobSnapshot({ - job_id: string, - snapshot_id: string, - timeout: string, - wait_for_completion: boolean -}) ----- -link:{ref}/ml-upgrade-job-model-snapshot.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the job - -|`snapshot_id` or `snapshotId` -|`string` - The ID of the snapshot - -|`timeout` -|`string` - How long should the API wait for the job to be opened and the old snapshot to be loaded. - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should the request wait until the task is complete before responding to the caller. Default is false. - -|=== - -[discrete] -=== ml.validate - -[source,ts] ----- -client.ml.validate({ - body: object -}) ----- -link:https://www.elastic.co/guide/en/machine-learning/current/ml-jobs.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - The job config - -|=== - -[discrete] -=== ml.validateDetector - -[source,ts] ----- -client.ml.validateDetector({ - body: object -}) ----- -link:https://www.elastic.co/guide/en/machine-learning/current/ml-jobs.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - The detector - -|=== - -[discrete] -=== monitoring.bulk -*Stability:* experimental -[source,ts] ----- -client.monitoring.bulk({ - type: string, - system_id: string, - system_api_version: string, - interval: string, - body: object -}) ----- -link:{ref}/monitor-elasticsearch-cluster.html[Documentation] + -[cols=2*] -|=== -|`type` -|`string` - Default document type for items which don't provide one + - -WARNING: This parameter has been deprecated. - -|`system_id` or `systemId` -|`string` - Identifier of the monitored system - -|`system_api_version` or `systemApiVersion` -|`string` - API Version of the monitored system - -|`interval` -|`string` - Collection interval (e.g., '10s' or '10000ms') of the payload - -|`body` -|`object` - The operation definition and data (action-data pairs), separated by newlines - -|=== - -[discrete] -=== msearch - -[source,ts] ----- -client.msearch({ - index: string | string[], - type: string | string[], - search_type: 'query_then_fetch' | 'dfs_query_then_fetch', - max_concurrent_searches: number, - typed_keys: boolean, - pre_filter_shard_size: number, - max_concurrent_shard_requests: number, - rest_total_hits_as_int: boolean, - ccs_minimize_roundtrips: boolean, - body: object -}) ----- -link:{ref}/search-multi-search.html[Documentation] + -{jsclient}/msearch_examples.html[Code Example] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to use as default - -|`type` -|`string \| string[]` - A comma-separated list of document types to use as default - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type - -|`max_concurrent_searches` or `maxConcurrentSearches` -|`number` - Controls the maximum number of concurrent searches the multi search api will execute - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|`pre_filter_shard_size` or `preFilterShardSize` -|`number` - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. - -|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` -|`number` - The number of concurrent shard requests each sub search executes concurrently per node. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + -_Default:_ `5` - -|`rest_total_hits_as_int` or `restTotalHitsAsInt` -|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response - -|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` -|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + -_Default:_ `true` - -|`body` -|`object` - The request definitions (metadata-search request definition pairs), separated by newlines - -|=== - -[discrete] -=== msearchTemplate - -[source,ts] ----- -client.msearchTemplate({ - index: string | string[], - type: string | string[], - search_type: 'query_then_fetch' | 'dfs_query_then_fetch', - typed_keys: boolean, - max_concurrent_searches: number, - rest_total_hits_as_int: boolean, - ccs_minimize_roundtrips: boolean, - body: object -}) ----- -link:{ref}/search-multi-search.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to use as default - -|`type` -|`string \| string[]` - A comma-separated list of document types to use as default - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|`max_concurrent_searches` or `maxConcurrentSearches` -|`number` - Controls the maximum number of concurrent searches the multi search api will execute - -|`rest_total_hits_as_int` or `restTotalHitsAsInt` -|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response - -|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` -|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + -_Default:_ `true` - -|`body` -|`object` - The request definitions (metadata-search request definition pairs), separated by newlines - -|=== - -[discrete] -=== mtermvectors - -[source,ts] ----- -client.mtermvectors({ - index: string, - type: string, - ids: string | string[], - term_statistics: boolean, - field_statistics: boolean, - fields: string | string[], - offsets: boolean, - positions: boolean, - payloads: boolean, - preference: string, - routing: string, - realtime: boolean, - version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force', - body: object -}) ----- -link:{ref}/docs-multi-termvectors.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The index in which the document resides. - -|`type` -|`string` - The type of the document. - -|`ids` -|`string \| string[]` - A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body - -|`term_statistics` or `termStatistics` -|`boolean` - Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". - -|`field_statistics` or `fieldStatistics` -|`boolean` - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + -_Default:_ `true` - -|`fields` -|`string \| string[]` - A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". - -|`offsets` -|`boolean` - Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + -_Default:_ `true` - -|`positions` -|`boolean` - Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + -_Default:_ `true` - -|`payloads` -|`boolean` - Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + -_Default:_ `true` - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs". - -|`routing` -|`string` - Specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs". - -|`realtime` -|`boolean` - Specifies if requests are real-time as opposed to near-real-time (default: true). - -|`version` -|`number` - Explicit version number for concurrency control - -|`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type - -|`body` -|`object` - Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation. - -|=== - -[discrete] -=== nodes.clearMeteringArchive -*Stability:* experimental -[source,ts] ----- -client.nodes.clearMeteringArchive({ - node_id: string | string[], - max_archive_version: number -}) ----- -link:{ref}/clear-repositories-metering-archive-api.html[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - Comma-separated list of node IDs or names used to limit returned information. - -|`max_archive_version` or `maxArchiveVersion` -|`number` - Specifies the maximum archive_version to be cleared from the archive. - -|=== - -[discrete] -=== nodes.getMeteringInfo -*Stability:* experimental -[source,ts] ----- -client.nodes.getMeteringInfo({ - node_id: string | string[] -}) ----- -link:{ref}/get-repositories-metering-api.html[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information. - -|=== - -[discrete] -=== nodes.hotThreads - -[source,ts] ----- -client.nodes.hotThreads({ - node_id: string | string[], - interval: string, - snapshots: number, - threads: number, - ignore_idle_threads: boolean, - type: 'cpu' | 'wait' | 'block', - timeout: string -}) ----- -link:{ref}/cluster-nodes-hot-threads.html[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`interval` -|`string` - The interval for the second sampling of threads - -|`snapshots` -|`number` - Number of samples of thread stacktrace (default: 10) - -|`threads` -|`number` - Specify the number of threads to provide information for (default: 3) - -|`ignore_idle_threads` or `ignoreIdleThreads` -|`boolean` - Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true) - -|`type` -|`'cpu' \| 'wait' \| 'block'` - The type to sample (default: cpu) - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -[discrete] -=== nodes.info - -[source,ts] ----- -client.nodes.info({ - node_id: string | string[], - metric: string | string[], - flat_settings: boolean, - timeout: string -}) ----- -link:{ref}/cluster-nodes-info.html[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`metric` -|`string \| string[]` - A comma-separated list of metrics you wish returned. Leave empty to return all. - -|`flat_settings` or `flatSettings` -|`boolean` - Return settings in flat format (default: false) - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -[discrete] -=== nodes.reloadSecureSettings - -[source,ts] ----- -client.nodes.reloadSecureSettings({ - node_id: string | string[], - timeout: string, - body: object -}) ----- -link:{ref}/secure-settings.html#reloadable-secure-settings[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes. - -|`timeout` -|`string` - Explicit operation timeout - -|`body` -|`object` - An object containing the password for the elasticsearch keystore - -|=== - -[discrete] -=== nodes.stats - -[source,ts] ----- -client.nodes.stats({ - node_id: string | string[], - metric: string | string[], - index_metric: string | string[], - completion_fields: string | string[], - fielddata_fields: string | string[], - fields: string | string[], - groups: boolean, - level: 'indices' | 'node' | 'shards', - types: string | string[], - timeout: string, - include_segment_file_sizes: boolean, - include_unloaded_segments: boolean -}) ----- -link:{ref}/cluster-nodes-stats.html[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`metric` -|`string \| string[]` - Limit the information returned to the specified metrics - -|`index_metric` or `indexMetric` -|`string \| string[]` - Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. - -|`completion_fields` or `completionFields` -|`string \| string[]` - A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) - -|`fielddata_fields` or `fielddataFields` -|`string \| string[]` - A comma-separated list of fields for `fielddata` index metric (supports wildcards) - -|`fields` -|`string \| string[]` - A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) - -|`groups` -|`boolean` - A comma-separated list of search groups for `search` index metric - -|`level` -|`'indices' \| 'node' \| 'shards'` - Return indices stats aggregated at index, node or shard level + -_Default:_ `node` - -|`types` -|`string \| string[]` - A comma-separated list of document types for the `indexing` index metric - -|`timeout` -|`string` - Explicit operation timeout - -|`include_segment_file_sizes` or `includeSegmentFileSizes` -|`boolean` - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) - -|`include_unloaded_segments` or `includeUnloadedSegments` -|`boolean` - If set to true segment stats will include stats for segments that are not currently loaded into memory - -|=== - -[discrete] -=== nodes.usage - -[source,ts] ----- -client.nodes.usage({ - node_id: string | string[], - metric: string | string[], - timeout: string -}) ----- -link:{ref}/cluster-nodes-usage.html[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`metric` -|`string \| string[]` - Limit the information returned to the specified metrics - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -[discrete] -=== openPointInTime - -[source,ts] ----- -client.openPointInTime({ - index: string | string[], - preference: string, - routing: string, - ignore_unavailable: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - keep_alive: string -}) ----- -link:{ref}/point-in-time-api.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to open point in time; use `_all` or empty string to perform the operation on all indices - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`routing` -|`string` - Specific routing value - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`keep_alive` or `keepAlive` -|`string` - Specific the time to live for the point in time - -|=== - -[discrete] -=== ping - -[source,ts] ----- -client.ping() ----- -link:{ref}/index.html[Documentation] + - - -[discrete] -=== putScript - -[source,ts] ----- -client.putScript({ - id: string, - context: string, - timeout: string, - master_timeout: string, - body: object -}) ----- -link:{ref}/modules-scripting.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - Script ID - -|`context` -|`string` - Script context - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`body` -|`object` - The document - -|=== - -[discrete] -=== rankEval -*Stability:* experimental -[source,ts] ----- -client.rankEval({ - index: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - search_type: 'query_then_fetch' | 'dfs_query_then_fetch', - body: object -}) ----- -link:{ref}/search-rank-eval.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type - -|`body` -|`object` - The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. - -|=== - -[discrete] -=== reindex - -[source,ts] ----- -client.reindex({ - refresh: boolean, - timeout: string, - wait_for_active_shards: string, - wait_for_completion: boolean, - requests_per_second: number, - scroll: string, - slices: number|string, - max_docs: number, - body: object -}) ----- -link:{ref}/docs-reindex.html[Documentation] + -{jsclient}/reindex_examples.html[Code Example] + -[cols=2*] -|=== -|`refresh` -|`boolean` - Should the affected indexes be refreshed? - -|`timeout` -|`string` - Time each individual bulk request should wait for shards that are unavailable. + -_Default:_ `1m` - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should the request should block until the reindex is complete. + -_Default:_ `true` - -|`requests_per_second` or `requestsPerSecond` -|`number` - The throttle to set on this request in sub-requests per second. -1 means no throttle. - -|`scroll` -|`string` - Control how long to keep the search context alive + -_Default:_ `5m` - -|`slices` -|`number\|string` - The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. + -_Default:_ `1` - -|`max_docs` or `maxDocs` -|`number` - Maximum number of documents to process (default: all documents) - -|`body` -|`object` - The search definition using the Query DSL and the prototype for the index request. - -|=== - -[discrete] -=== reindexRethrottle - -[source,ts] ----- -client.reindexRethrottle({ - task_id: string, - requests_per_second: number -}) ----- -link:{ref}/docs-reindex.html[Documentation] + -[cols=2*] -|=== -|`task_id` or `taskId` -|`string` - The task id to rethrottle - -|`requests_per_second` or `requestsPerSecond` -|`number` - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. - -|=== - -[discrete] -=== renderSearchTemplate - -[source,ts] ----- -client.renderSearchTemplate({ - id: string, - body: object -}) ----- -link:{ref}/render-search-template-api.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The id of the stored search template - -|`body` -|`object` - The search definition template and its params - -|=== - -[discrete] -=== rollup.deleteJob -*Stability:* experimental -[source,ts] ----- -client.rollup.deleteJob({ - id: string -}) ----- -link:{ref}/rollup-delete-job.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the job to delete - -|=== - -[discrete] -=== rollup.getJobs -*Stability:* experimental -[source,ts] ----- -client.rollup.getJobs({ - id: string -}) ----- -link:{ref}/rollup-get-job.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the job(s) to fetch. Accepts glob patterns, or left blank for all jobs - -|=== - -[discrete] -=== rollup.getRollupCaps -*Stability:* experimental -[source,ts] ----- -client.rollup.getRollupCaps({ - id: string -}) ----- -link:{ref}/rollup-get-rollup-caps.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the index to check rollup capabilities on, or left blank for all jobs - -|=== - -[discrete] -=== rollup.getRollupIndexCaps -*Stability:* experimental -[source,ts] ----- -client.rollup.getRollupIndexCaps({ - index: string -}) ----- -link:{ref}/rollup-get-rollup-index-caps.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The rollup index or index pattern to obtain rollup capabilities from. - -|=== - -[discrete] -=== rollup.putJob -*Stability:* experimental -[source,ts] ----- -client.rollup.putJob({ - id: string, - body: object -}) ----- -link:{ref}/rollup-put-job.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the job to create - -|`body` -|`object` - The job configuration - -|=== - -[discrete] -=== rollup.rollup -*Stability:* experimental -[source,ts] ----- -client.rollup.rollup({ - index: string, - rollup_index: string, - body: object -}) ----- -link:{ref}/xpack-rollup.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The index to roll up - -|`rollup_index` or `rollupIndex` -|`string` - The name of the rollup index to create - -|`body` -|`object` - The rollup configuration - -|=== - -[discrete] -=== rollup.rollupSearch -*Stability:* experimental -[source,ts] ----- -client.rollup.rollupSearch({ - index: string | string[], - type: string, - typed_keys: boolean, - rest_total_hits_as_int: boolean, - body: object -}) ----- -link:{ref}/rollup-search.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - The indices or index-pattern(s) (containing rollup or regular data) that should be searched - -|`type` -|`string` - The doc type inside the index + - -WARNING: This parameter has been deprecated. - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|`rest_total_hits_as_int` or `restTotalHitsAsInt` -|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response - -|`body` -|`object` - The search request body - -|=== - -[discrete] -=== rollup.startJob -*Stability:* experimental -[source,ts] ----- -client.rollup.startJob({ - id: string -}) ----- -link:{ref}/rollup-start-job.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the job to start - -|=== - -[discrete] -=== rollup.stopJob -*Stability:* experimental -[source,ts] ----- -client.rollup.stopJob({ - id: string, - wait_for_completion: boolean, - timeout: string -}) ----- -link:{ref}/rollup-stop-job.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the job to stop - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - True if the API should block until the job has fully stopped, false if should be executed async. Defaults to false. - -|`timeout` -|`string` - Block for (at maximum) the specified duration while waiting for the job to stop. Defaults to 30s. - -|=== - -[discrete] -=== scriptsPainlessExecute -*Stability:* experimental -[source,ts] ----- -client.scriptsPainlessExecute({ - body: object -}) ----- -link:https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - The script to execute - -|=== - -[discrete] -=== scroll - -[source,ts] ----- -client.scroll({ - scroll_id: string, - scroll: string, - rest_total_hits_as_int: boolean, - body: object -}) ----- -link:{ref}/search-request-body.html#request-body-search-scroll[Documentation] + -{jsclient}/scroll_examples.html[Code Example] + -[cols=2*] -|=== -|`scroll_id` or `scrollId` -|`string` - The scroll ID + - -WARNING: This parameter has been deprecated. - -|`scroll` -|`string` - Specify how long a consistent view of the index should be maintained for scrolled search - -|`rest_total_hits_as_int` or `restTotalHitsAsInt` -|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response - -|`body` -|`object` - The scroll ID if not passed by URL or query parameter. - -|=== - -[discrete] -=== search - -[source,ts] ----- -client.search({ - index: string | string[], - type: string | string[], - analyzer: string, - analyze_wildcard: boolean, - ccs_minimize_roundtrips: boolean, - default_operator: 'AND' | 'OR', - df: string, - explain: boolean, - stored_fields: string | string[], - docvalue_fields: string | string[], - from: number, - ignore_unavailable: boolean, - ignore_throttled: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - lenient: boolean, - preference: string, - q: string, - routing: string | string[], - scroll: string, - search_type: 'query_then_fetch' | 'dfs_query_then_fetch', - size: number, - sort: string | string[], - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - terminate_after: number, - stats: string | string[], - suggest_field: string, - suggest_mode: 'missing' | 'popular' | 'always', - suggest_size: number, - suggest_text: string, - timeout: string, - track_scores: boolean, - track_total_hits: boolean, - allow_partial_search_results: boolean, - typed_keys: boolean, - version: boolean, - seq_no_primary_term: boolean, - request_cache: boolean, - batched_reduce_size: number, - max_concurrent_shard_requests: number, - pre_filter_shard_size: number, - rest_total_hits_as_int: boolean, - min_compatible_shard_node: string, - body: object -}) ----- -link:{ref}/search-search.html[Documentation] + -{jsclient}/search_examples.html[Code Example] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`type` -|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types - -|`analyzer` -|`string` - The analyzer to use for the query string - -|`analyze_wildcard` or `analyzeWildcard` -|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) - -|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` -|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + -_Default:_ `true` - -|`default_operator` or `defaultOperator` -|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + -_Default:_ `OR` - -|`df` -|`string` - The field to use as default where no field prefix is given in the query string - -|`explain` -|`boolean` - Specify whether to return detailed information about score computation as part of a hit - -|`stored_fields` or `storedFields` -|`string \| string[]` - A comma-separated list of stored fields to return as part of a hit - -|`docvalue_fields` or `docvalueFields` -|`string \| string[]` - A comma-separated list of fields to return as the docvalue representation of a field for each hit - -|`from` -|`number` - Starting offset (default: 0) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`ignore_throttled` or `ignoreThrottled` -|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`lenient` -|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`q` -|`string` - Query in the Lucene query string syntax - -|`routing` -|`string \| string[]` - A comma-separated list of specific routing values - -|`scroll` -|`string` - Specify how long a consistent view of the index should be maintained for scrolled search - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type - -|`size` -|`number` - Number of hits to return (default: 10) - -|`sort` -|`string \| string[]` - A comma-separated list of : pairs - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`terminate_after` or `terminateAfter` -|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. - -|`stats` -|`string \| string[]` - Specific 'tag' of the request for logging and statistical purposes - -|`suggest_field` or `suggestField` -|`string` - Specify which field to use for suggestions - -|`suggest_mode` or `suggestMode` -|`'missing' \| 'popular' \| 'always'` - Specify suggest mode + -_Default:_ `missing` - -|`suggest_size` or `suggestSize` -|`number` - How many suggestions to return in response - -|`suggest_text` or `suggestText` -|`string` - The source text for which the suggestions should be returned - -|`timeout` -|`string` - Explicit operation timeout - -|`track_scores` or `trackScores` -|`boolean` - Whether to calculate and return scores even if they are not used for sorting - -|`track_total_hits` or `trackTotalHits` -|`boolean` - Indicate if the number of documents that match the query should be tracked - -|`allow_partial_search_results` or `allowPartialSearchResults` -|`boolean` - Indicate if an error should be returned if there is a partial search failure or timeout + -_Default:_ `true` - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|`version` -|`boolean` - Specify whether to return document version as part of a hit - -|`seq_no_primary_term` or `seqNoPrimaryTerm` -|`boolean` - Specify whether to return sequence number and primary term of the last modification of each hit - -|`request_cache` or `requestCache` -|`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting - -|`batched_reduce_size` or `batchedReduceSize` -|`number` - The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. + -_Default:_ `512` - -|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` -|`number` - The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + -_Default:_ `5` - -|`pre_filter_shard_size` or `preFilterShardSize` -|`number` - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. - -|`rest_total_hits_as_int` or `restTotalHitsAsInt` -|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response - -|`min_compatible_shard_node` or `minCompatibleShardNode` -|`string` - The minimum compatible version that all shards involved in search should have for this request to be successful - -|`body` -|`object` - The search definition using the Query DSL - -|=== - -[discrete] -=== searchShards - -[source,ts] ----- -client.searchShards({ - index: string | string[], - preference: string, - routing: string, - local: boolean, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/search-shards.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`routing` -|`string` - Specific routing value - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - -[discrete] -=== searchTemplate - -[source,ts] ----- -client.searchTemplate({ - index: string | string[], - type: string | string[], - ignore_unavailable: boolean, - ignore_throttled: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - preference: string, - routing: string | string[], - scroll: string, - search_type: 'query_then_fetch' | 'dfs_query_then_fetch', - explain: boolean, - profile: boolean, - typed_keys: boolean, - rest_total_hits_as_int: boolean, - ccs_minimize_roundtrips: boolean, - body: object -}) ----- -link:{ref}/search-template.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`type` -|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`ignore_throttled` or `ignoreThrottled` -|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`routing` -|`string \| string[]` - A comma-separated list of specific routing values - -|`scroll` -|`string` - Specify how long a consistent view of the index should be maintained for scrolled search - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type - -|`explain` -|`boolean` - Specify whether to return detailed information about score computation as part of a hit - -|`profile` -|`boolean` - Specify whether to profile the query execution - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|`rest_total_hits_as_int` or `restTotalHitsAsInt` -|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response - -|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` -|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + -_Default:_ `true` - -|`body` -|`object` - The search definition template and its params - -|=== - -[discrete] -=== searchableSnapshots.cacheStats -*Stability:* experimental -[source,ts] ----- -client.searchableSnapshots.cacheStats({ - node_id: string | string[] -}) ----- -link:{ref}/searchable-snapshots-apis.html[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|=== - -[discrete] -=== searchableSnapshots.clearCache -*Stability:* experimental -[source,ts] ----- -client.searchableSnapshots.clearCache({ - index: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'none' | 'all' -}) ----- -link:{ref}/searchable-snapshots-apis.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - -[discrete] -=== searchableSnapshots.mount -*Stability:* experimental -[source,ts] ----- -client.searchableSnapshots.mount({ - repository: string, - snapshot: string, - master_timeout: string, - wait_for_completion: boolean, - storage: string, - body: object -}) ----- -link:{ref}/searchable-snapshots-api-mount-snapshot.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - The name of the repository containing the snapshot of the index to mount - -|`snapshot` -|`string` - The name of the snapshot of the index to mount - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should this request wait until the operation has completed before returning - -|`storage` -|`string` - Selects the kind of local storage used to accelerate searches. Experimental, and defaults to `full_copy` - -|`body` -|`object` - The restore configuration for mounting the snapshot as searchable - -|=== - -[discrete] -=== searchableSnapshots.repositoryStats -*Stability:* experimental -[source,ts] ----- -client.searchableSnapshots.repositoryStats({ - repository: string -}) ----- -link:{ref}/searchable-snapshots-apis.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - The repository for which to get the stats for - -|=== - -[discrete] -=== searchableSnapshots.stats -*Stability:* experimental -[source,ts] ----- -client.searchableSnapshots.stats({ - index: string | string[], - level: 'cluster' | 'indices' | 'shards' -}) ----- -link:{ref}/searchable-snapshots-apis.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names - -|`level` -|`'cluster' \| 'indices' \| 'shards'` - Return stats aggregated at cluster, index or shard level + -_Default:_ `indices` - -|=== - -[discrete] -=== security.authenticate - -[source,ts] ----- -client.security.authenticate() ----- -link:{ref}/security-api-authenticate.html[Documentation] + - - -[discrete] -=== security.changePassword - -[source,ts] ----- -client.security.changePassword({ - username: string, - refresh: 'true' | 'false' | 'wait_for', - body: object -}) ----- -link:{ref}/security-api-change-password.html[Documentation] + -[cols=2*] -|=== -|`username` -|`string` - The username of the user to change the password for - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - -|`body` -|`object` - the new password for the user - -|=== - -[discrete] -=== security.clearApiKeyCache - -[source,ts] ----- -client.security.clearApiKeyCache({ - ids: string | string[] -}) ----- -link:{ref}/security-api-clear-api-key-cache.html[Documentation] + -[cols=2*] -|=== -|`ids` -|`string \| string[]` - A comma-separated list of IDs of API keys to clear from the cache - -|=== - -[discrete] -=== security.clearCachedPrivileges - -[source,ts] ----- -client.security.clearCachedPrivileges({ - application: string | string[] -}) ----- -link:{ref}/security-api-clear-privilege-cache.html[Documentation] + -[cols=2*] -|=== -|`application` -|`string \| string[]` - A comma-separated list of application names - -|=== - -[discrete] -=== security.clearCachedRealms - -[source,ts] ----- -client.security.clearCachedRealms({ - realms: string | string[], - usernames: string | string[] -}) ----- -link:{ref}/security-api-clear-cache.html[Documentation] + -[cols=2*] -|=== -|`realms` -|`string \| string[]` - Comma-separated list of realms to clear - -|`usernames` -|`string \| string[]` - Comma-separated list of usernames to clear from the cache - -|=== - -[discrete] -=== security.clearCachedRoles - -[source,ts] ----- -client.security.clearCachedRoles({ - name: string | string[] -}) ----- -link:{ref}/security-api-clear-role-cache.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - Role name - -|=== - -[discrete] -=== security.clearCachedServiceTokens -*Stability:* beta -[source,ts] ----- -client.security.clearCachedServiceTokens({ - namespace: string, - service: string, - name: string | string[] -}) ----- -link:{ref}/security-api-clear-service-token-caches.html[Documentation] + -[cols=2*] -|=== -|`namespace` -|`string` - An identifier for the namespace - -|`service` -|`string` - An identifier for the service name - -|`name` -|`string \| string[]` - A comma-separated list of service token names - -|=== - -[discrete] -=== security.createApiKey - -[source,ts] ----- -client.security.createApiKey({ - refresh: 'true' | 'false' | 'wait_for', - body: object -}) ----- -link:{ref}/security-api-create-api-key.html[Documentation] + -[cols=2*] -|=== -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - -|`body` -|`object` - The api key request to create an API key - -|=== - -[discrete] -=== security.createServiceToken -*Stability:* beta -[source,ts] ----- -client.security.createServiceToken({ - namespace: string, - service: string, - name: string, - refresh: 'true' | 'false' | 'wait_for' -}) ----- -link:{ref}/security-api-create-service-token.html[Documentation] + -[cols=2*] -|=== -|`namespace` -|`string` - An identifier for the namespace - -|`service` -|`string` - An identifier for the service name - -|`name` -|`string` - An identifier for the token name - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - -|=== - -[discrete] -=== security.deletePrivileges - -[source,ts] ----- -client.security.deletePrivileges({ - application: string, - name: string, - refresh: 'true' | 'false' | 'wait_for' -}) ----- -link:{ref}/security-api-delete-privilege.html[Documentation] + -[cols=2*] -|=== -|`application` -|`string` - Application name - -|`name` -|`string` - Privilege name - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - -|=== - -[discrete] -=== security.deleteRole - -[source,ts] ----- -client.security.deleteRole({ - name: string, - refresh: 'true' | 'false' | 'wait_for' -}) ----- -link:{ref}/security-api-delete-role.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - Role name - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - -|=== - -[discrete] -=== security.deleteRoleMapping - -[source,ts] ----- -client.security.deleteRoleMapping({ - name: string, - refresh: 'true' | 'false' | 'wait_for' -}) ----- -link:{ref}/security-api-delete-role-mapping.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - Role-mapping name - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - -|=== - -[discrete] -=== security.deleteServiceToken -*Stability:* beta -[source,ts] ----- -client.security.deleteServiceToken({ - namespace: string, - service: string, - name: string, - refresh: 'true' | 'false' | 'wait_for' -}) ----- -link:{ref}/security-api-delete-service-token.html[Documentation] + -[cols=2*] -|=== -|`namespace` -|`string` - An identifier for the namespace - -|`service` -|`string` - An identifier for the service name - -|`name` -|`string` - An identifier for the token name - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - -|=== - -[discrete] -=== security.deleteUser - -[source,ts] ----- -client.security.deleteUser({ - username: string, - refresh: 'true' | 'false' | 'wait_for' -}) ----- -link:{ref}/security-api-delete-user.html[Documentation] + -[cols=2*] -|=== -|`username` -|`string` - username - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - -|=== - -[discrete] -=== security.disableUser - -[source,ts] ----- -client.security.disableUser({ - username: string, - refresh: 'true' | 'false' | 'wait_for' -}) ----- -link:{ref}/security-api-disable-user.html[Documentation] + -[cols=2*] -|=== -|`username` -|`string` - The username of the user to disable - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - -|=== - -[discrete] -=== security.enableUser - -[source,ts] ----- -client.security.enableUser({ - username: string, - refresh: 'true' | 'false' | 'wait_for' -}) ----- -link:{ref}/security-api-enable-user.html[Documentation] + -[cols=2*] -|=== -|`username` -|`string` - The username of the user to enable - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - -|=== - -[discrete] -=== security.getApiKey - -[source,ts] ----- -client.security.getApiKey({ - id: string, - name: string, - username: string, - realm_name: string, - owner: boolean -}) ----- -link:{ref}/security-api-get-api-key.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - API key id of the API key to be retrieved - -|`name` -|`string` - API key name of the API key to be retrieved - -|`username` -|`string` - user name of the user who created this API key to be retrieved - -|`realm_name` or `realmName` -|`string` - realm name of the user who created this API key to be retrieved - -|`owner` -|`boolean` - flag to query API keys owned by the currently authenticated user - -|=== - -[discrete] -=== security.getBuiltinPrivileges - -[source,ts] ----- -client.security.getBuiltinPrivileges() ----- -link:{ref}/security-api-get-builtin-privileges.html[Documentation] + - - -[discrete] -=== security.getPrivileges - -[source,ts] ----- -client.security.getPrivileges({ - application: string, - name: string -}) ----- -link:{ref}/security-api-get-privileges.html[Documentation] + -[cols=2*] -|=== -|`application` -|`string` - Application name - -|`name` -|`string` - Privilege name - -|=== - -[discrete] -=== security.getRole - -[source,ts] ----- -client.security.getRole({ - name: string | string[] -}) ----- -link:{ref}/security-api-get-role.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of role names - -|=== - -[discrete] -=== security.getRoleMapping - -[source,ts] ----- -client.security.getRoleMapping({ - name: string | string[] -}) ----- -link:{ref}/security-api-get-role-mapping.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of role-mapping names - -|=== - -[discrete] -=== security.getServiceAccounts -*Stability:* beta -[source,ts] ----- -client.security.getServiceAccounts({ - namespace: string, - service: string -}) ----- -link:{ref}/security-api-get-service-accounts.html[Documentation] + -[cols=2*] -|=== -|`namespace` -|`string` - An identifier for the namespace - -|`service` -|`string` - An identifier for the service name - -|=== - -[discrete] -=== security.getServiceCredentials -*Stability:* beta -[source,ts] ----- -client.security.getServiceCredentials({ - namespace: string, - service: string -}) ----- -link:{ref}/security-api-get-service-credentials.html[Documentation] + -[cols=2*] -|=== -|`namespace` -|`string` - An identifier for the namespace - -|`service` -|`string` - An identifier for the service name - -|=== - -[discrete] -=== security.getToken - -[source,ts] ----- -client.security.getToken({ - body: object -}) ----- -link:{ref}/security-api-get-token.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - The token request to get - -|=== - -[discrete] -=== security.getUser - -[source,ts] ----- -client.security.getUser({ - username: string | string[] -}) ----- -link:{ref}/security-api-get-user.html[Documentation] + -[cols=2*] -|=== -|`username` -|`string \| string[]` - A comma-separated list of usernames - -|=== - -[discrete] -=== security.getUserPrivileges - -[source,ts] ----- -client.security.getUserPrivileges() ----- -link:{ref}/security-api-get-privileges.html[Documentation] + - - -[discrete] -=== security.grantApiKey - -[source,ts] ----- -client.security.grantApiKey({ - refresh: 'true' | 'false' | 'wait_for', - body: object -}) ----- -link:{ref}/security-api-grant-api-key.html[Documentation] + -[cols=2*] -|=== -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - -|`body` -|`object` - The api key request to create an API key - -|=== - -[discrete] -=== security.hasPrivileges - -[source,ts] ----- -client.security.hasPrivileges({ - user: string, - body: object -}) ----- -link:{ref}/security-api-has-privileges.html[Documentation] + -[cols=2*] -|=== -|`user` -|`string` - Username - -|`body` -|`object` - The privileges to test - -|=== - -[discrete] -=== security.invalidateApiKey - -[source,ts] ----- -client.security.invalidateApiKey({ - body: object -}) ----- -link:{ref}/security-api-invalidate-api-key.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - The api key request to invalidate API key(s) - -|=== - -[discrete] -=== security.invalidateToken - -[source,ts] ----- -client.security.invalidateToken({ - body: object -}) ----- -link:{ref}/security-api-invalidate-token.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - The token to invalidate - -|=== - -[discrete] -=== security.putPrivileges - -[source,ts] ----- -client.security.putPrivileges({ - refresh: 'true' | 'false' | 'wait_for', - body: object -}) ----- -link:{ref}/security-api-put-privileges.html[Documentation] + -[cols=2*] -|=== -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - -|`body` -|`object` - The privilege(s) to add - -|=== - -[discrete] -=== security.putRole - -[source,ts] ----- -client.security.putRole({ - name: string, - refresh: 'true' | 'false' | 'wait_for', - body: object -}) ----- -link:{ref}/security-api-put-role.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - Role name - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - -|`body` -|`object` - The role to add - -|=== - -[discrete] -=== security.putRoleMapping - -[source,ts] ----- -client.security.putRoleMapping({ - name: string, - refresh: 'true' | 'false' | 'wait_for', - body: object -}) ----- -link:{ref}/security-api-put-role-mapping.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - Role-mapping name - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - -|`body` -|`object` - The role mapping to add - -|=== - -[discrete] -=== security.putUser - -[source,ts] ----- -client.security.putUser({ - username: string, - refresh: 'true' | 'false' | 'wait_for', - body: object -}) ----- -link:{ref}/security-api-put-user.html[Documentation] + -[cols=2*] -|=== -|`username` -|`string` - The username of the User - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. - -|`body` -|`object` - The user to add - -|=== - -[discrete] -=== security.samlAuthenticate - -[source,ts] ----- -client.security.samlAuthenticate({ - body: object -}) ----- -link:{ref}/security-api-saml-authenticate.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - The SAML response to authenticate - -|=== - -[discrete] -=== security.samlCompleteLogout - -[source,ts] ----- -client.security.samlCompleteLogout({ - body: object -}) ----- -link:{ref}/security-api-saml-complete-logout.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - The logout response to verify - -|=== - -[discrete] -=== security.samlInvalidate - -[source,ts] ----- -client.security.samlInvalidate({ - body: object -}) ----- -link:{ref}/security-api-saml-invalidate.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - The LogoutRequest message - -|=== - -[discrete] -=== security.samlLogout - -[source,ts] ----- -client.security.samlLogout({ - body: object -}) ----- -link:{ref}/security-api-saml-logout.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - The tokens to invalidate - -|=== - -[discrete] -=== security.samlPrepareAuthentication - -[source,ts] ----- -client.security.samlPrepareAuthentication({ - body: object -}) ----- -link:{ref}/security-api-saml-prepare-authentication.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - The realm for which to create the authentication request, identified by either its name or the ACS URL - -|=== - -[discrete] -=== security.samlServiceProviderMetadata - -[source,ts] ----- -client.security.samlServiceProviderMetadata({ - realm_name: string -}) ----- -link:{ref}/security-api-saml-sp-metadata.html[Documentation] + -[cols=2*] -|=== -|`realm_name` or `realmName` -|`string` - The name of the SAML realm to get the metadata for - -|=== - -[discrete] -=== shutdown.deleteNode -*Stability:* experimental -[source,ts] ----- -client.shutdown.deleteNode({ - node_id: string -}) ----- -link:https://www.elastic.co/guide/en/elasticsearch/reference/current[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string` - The node id of node to be removed from the shutdown state - -|=== - -[discrete] -=== shutdown.getNode -*Stability:* experimental -[source,ts] ----- -client.shutdown.getNode({ - node_id: string -}) ----- -link:https://www.elastic.co/guide/en/elasticsearch/reference/current[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string` - Which node for which to retrieve the shutdown status - -|=== - -[discrete] -=== shutdown.putNode -*Stability:* experimental -[source,ts] ----- -client.shutdown.putNode({ - node_id: string, - body: object -}) ----- -link:https://www.elastic.co/guide/en/elasticsearch/reference/current[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string` - The node id of node to be shut down - -|`body` -|`object` - The shutdown type definition to register - -|=== - -[discrete] -=== slm.deleteLifecycle - -[source,ts] ----- -client.slm.deleteLifecycle({ - policy_id: string -}) ----- -link:{ref}/slm-api-delete-policy.html[Documentation] + -[cols=2*] -|=== -|`policy_id` or `policyId` -|`string` - The id of the snapshot lifecycle policy to remove - -|=== - -[discrete] -=== slm.executeLifecycle - -[source,ts] ----- -client.slm.executeLifecycle({ - policy_id: string -}) ----- -link:{ref}/slm-api-execute-lifecycle.html[Documentation] + -[cols=2*] -|=== -|`policy_id` or `policyId` -|`string` - The id of the snapshot lifecycle policy to be executed - -|=== - -[discrete] -=== slm.executeRetention - -[source,ts] ----- -client.slm.executeRetention() ----- -link:{ref}/slm-api-execute-retention.html[Documentation] + - - -[discrete] -=== slm.getLifecycle - -[source,ts] ----- -client.slm.getLifecycle({ - policy_id: string | string[] -}) ----- -link:{ref}/slm-api-get-policy.html[Documentation] + -[cols=2*] -|=== -|`policy_id` or `policyId` -|`string \| string[]` - Comma-separated list of snapshot lifecycle policies to retrieve - -|=== - -[discrete] -=== slm.getStats - -[source,ts] ----- -client.slm.getStats() ----- -link:{ref}/slm-api-get-stats.html[Documentation] + - - -[discrete] -=== slm.getStatus - -[source,ts] ----- -client.slm.getStatus() ----- -link:{ref}/slm-api-get-status.html[Documentation] + - - -[discrete] -=== slm.putLifecycle - -[source,ts] ----- -client.slm.putLifecycle({ - policy_id: string, - body: object -}) ----- -link:{ref}/slm-api-put-policy.html[Documentation] + -[cols=2*] -|=== -|`policy_id` or `policyId` -|`string` - The id of the snapshot lifecycle policy - -|`body` -|`object` - The snapshot lifecycle policy definition to register - -|=== - -[discrete] -=== slm.start - -[source,ts] ----- -client.slm.start() ----- -link:{ref}/slm-api-start.html[Documentation] + - - -[discrete] -=== slm.stop - -[source,ts] ----- -client.slm.stop() ----- -link:{ref}/slm-api-stop.html[Documentation] + - - -[discrete] -=== snapshot.cleanupRepository - -[source,ts] ----- -client.snapshot.cleanupRepository({ - repository: string, - master_timeout: string, - timeout: string -}) ----- -link:{ref}/clean-up-snapshot-repo-api.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -[discrete] -=== snapshot.clone - -[source,ts] ----- -client.snapshot.clone({ - repository: string, - snapshot: string, - target_snapshot: string, - master_timeout: string, - body: object -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`snapshot` -|`string` - The name of the snapshot to clone from - -|`target_snapshot` or `targetSnapshot` -|`string` - The name of the cloned snapshot to create - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`body` -|`object` - The snapshot clone definition - -|=== - -[discrete] -=== snapshot.create - -[source,ts] ----- -client.snapshot.create({ - repository: string, - snapshot: string, - master_timeout: string, - wait_for_completion: boolean, - body: object -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`snapshot` -|`string` - A snapshot name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should this request wait until the operation has completed before returning - -|`body` -|`object` - The snapshot definition - -|=== - -[discrete] -=== snapshot.createRepository - -[source,ts] ----- -client.snapshot.createRepository({ - repository: string, - master_timeout: string, - timeout: string, - verify: boolean, - body: object -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|`verify` -|`boolean` - Whether to verify the repository after creation - -|`body` -|`object` - The repository definition - -|=== - -[discrete] -=== snapshot.delete - -[source,ts] ----- -client.snapshot.delete({ - repository: string, - snapshot: string, - master_timeout: string -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`snapshot` -|`string` - A snapshot name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|=== - -[discrete] -=== snapshot.deleteRepository - -[source,ts] ----- -client.snapshot.deleteRepository({ - repository: string | string[], - master_timeout: string, - timeout: string -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string \| string[]` - Name of the snapshot repository to unregister. Wildcard (`*`) patterns are supported. - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -[discrete] -=== snapshot.get - -[source,ts] ----- -client.snapshot.get({ - repository: string, - snapshot: string | string[], - master_timeout: string, - ignore_unavailable: boolean, - index_details: boolean, - include_repository: boolean, - verbose: boolean -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`snapshot` -|`string \| string[]` - A comma-separated list of snapshot names - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown - -|`index_details` or `indexDetails` -|`boolean` - Whether to include details of each index in the snapshot, if those details are available. Defaults to false. - -|`include_repository` or `includeRepository` -|`boolean` - Whether to include the repository name in the snapshot info. Defaults to true. - -|`verbose` -|`boolean` - Whether to show verbose snapshot info or only show the basic info found in the repository index blob - -|=== - -[discrete] -=== snapshot.getRepository - -[source,ts] ----- -client.snapshot.getRepository({ - repository: string | string[], - master_timeout: string, - local: boolean -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string \| string[]` - A comma-separated list of repository names - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|=== - -[discrete] -=== snapshot.repositoryAnalyze - -[source,ts] ----- -client.snapshot.repositoryAnalyze({ - repository: string, - blob_count: number, - concurrency: number, - read_node_count: number, - early_read_node_count: number, - seed: number, - rare_action_probability: number, - max_blob_size: string, - max_total_data_size: string, - timeout: string, - detailed: boolean, - rarely_abort_writes: boolean -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`blob_count` or `blobCount` -|`number` - Number of blobs to create during the test. Defaults to 100. - -|`concurrency` -|`number` - Number of operations to run concurrently during the test. Defaults to 10. - -|`read_node_count` or `readNodeCount` -|`number` - Number of nodes on which to read a blob after writing. Defaults to 10. - -|`early_read_node_count` or `earlyReadNodeCount` -|`number` - Number of nodes on which to perform an early read on a blob, i.e. before writing has completed. Early reads are rare actions so the 'rare_action_probability' parameter is also relevant. Defaults to 2. - -|`seed` -|`number` - Seed for the random number generator used to create the test workload. Defaults to a random value. - -|`rare_action_probability` or `rareActionProbability` -|`number` - Probability of taking a rare action such as an early read or an overwrite. Defaults to 0.02. - -|`max_blob_size` or `maxBlobSize` -|`string` - Maximum size of a blob to create during the test, e.g '1gb' or '100mb'. Defaults to '10mb'. - -|`max_total_data_size` or `maxTotalDataSize` -|`string` - Maximum total size of all blobs to create during the test, e.g '1tb' or '100gb'. Defaults to '1gb'. - -|`timeout` -|`string` - Explicit operation timeout. Defaults to '30s'. - -|`detailed` -|`boolean` - Whether to return detailed results or a summary. Defaults to 'false' so that only the summary is returned. - -|`rarely_abort_writes` or `rarelyAbortWrites` -|`boolean` - Whether to rarely abort writes before they complete. Defaults to 'true'. - -|=== - -[discrete] -=== snapshot.restore - -[source,ts] ----- -client.snapshot.restore({ - repository: string, - snapshot: string, - master_timeout: string, - wait_for_completion: boolean, - body: object -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`snapshot` -|`string` - A snapshot name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should this request wait until the operation has completed before returning - -|`body` -|`object` - Details of what to restore - -|=== - -[discrete] -=== snapshot.status - -[source,ts] ----- -client.snapshot.status({ - repository: string, - snapshot: string | string[], - master_timeout: string, - ignore_unavailable: boolean -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`snapshot` -|`string \| string[]` - A comma-separated list of snapshot names - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown - -|=== - -[discrete] -=== snapshot.verifyRepository - -[source,ts] ----- -client.snapshot.verifyRepository({ - repository: string, - master_timeout: string, - timeout: string -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -[discrete] -=== sql.clearCursor - -[source,ts] ----- -client.sql.clearCursor({ - body: object -}) ----- -link:{ref}/sql-pagination.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - Specify the cursor value in the `cursor` element to clean the cursor. - -|=== - -[discrete] -=== sql.deleteAsync - -[source,ts] ----- -client.sql.deleteAsync({ - id: string -}) ----- -link:{ref}/delete-async-sql-search-api.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The async search ID - -|=== - -[discrete] -=== sql.getAsync - -[source,ts] ----- -client.sql.getAsync({ - id: string, - delimiter: string, - format: string, - keep_alive: string, - wait_for_completion_timeout: string -}) ----- -link:{ref}/get-async-sql-search-api.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The async search ID - -|`delimiter` -|`string` - Separator for CSV results + -_Default:_ `,` - -|`format` -|`string` - Short version of the Accept header, e.g. json, yaml - -|`keep_alive` or `keepAlive` -|`string` - Retention period for the search and its results + -_Default:_ `5d` - -|`wait_for_completion_timeout` or `waitForCompletionTimeout` -|`string` - Duration to wait for complete results - -|=== - -[discrete] -=== sql.getAsyncStatus - -[source,ts] ----- -client.sql.getAsyncStatus({ - id: string -}) ----- -link:{ref}/get-async-sql-search-status-api.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The async search ID - -|=== - -[discrete] -=== sql.query - -[source,ts] ----- -client.sql.query({ - format: string, - body: object -}) ----- -link:{ref}/sql-rest-overview.html[Documentation] + -{jsclient}/sql_query_examples.html[Code Example] + -[cols=2*] -|=== -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`body` -|`object` - Use the `query` element to start a query. Use the `cursor` element to continue a query. - -|=== - -[discrete] -=== sql.translate - -[source,ts] ----- -client.sql.translate({ - body: object -}) ----- -link:{ref}/sql-translate.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - Specify the query in the `query` element. - -|=== - -[discrete] -=== ssl.certificates - -[source,ts] ----- -client.ssl.certificates() ----- -link:{ref}/security-api-ssl.html[Documentation] + - - -[discrete] -=== tasks.cancel -*Stability:* experimental -[source,ts] ----- -client.tasks.cancel({ - task_id: string, - nodes: string | string[], - actions: string | string[], - parent_task_id: string, - wait_for_completion: boolean -}) ----- -link:{ref}/tasks.html[Documentation] + -[cols=2*] -|=== -|`task_id` or `taskId` -|`string` - Cancel the task with specified task id (node_id:task_number) - -|`nodes` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`actions` -|`string \| string[]` - A comma-separated list of actions that should be cancelled. Leave empty to cancel all. - -|`parent_task_id` or `parentTaskId` -|`string` - Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false - -|=== - -[discrete] -=== tasks.get -*Stability:* experimental -[source,ts] ----- -client.tasks.get({ - task_id: string, - wait_for_completion: boolean, - timeout: string -}) ----- -link:{ref}/tasks.html[Documentation] + -[cols=2*] -|=== -|`task_id` or `taskId` -|`string` - Return the task with specified id (node_id:task_number) - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Wait for the matching tasks to complete (default: false) - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -[discrete] -=== tasks.list -*Stability:* experimental -[source,ts] ----- -client.tasks.list({ - nodes: string | string[], - actions: string | string[], - detailed: boolean, - parent_task_id: string, - wait_for_completion: boolean, - group_by: 'nodes' | 'parents' | 'none', - timeout: string -}) ----- -link:{ref}/tasks.html[Documentation] + -[cols=2*] -|=== -|`nodes` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`actions` -|`string \| string[]` - A comma-separated list of actions that should be returned. Leave empty to return all. - -|`detailed` -|`boolean` - Return detailed task information (default: false) - -|`parent_task_id` or `parentTaskId` -|`string` - Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Wait for the matching tasks to complete (default: false) - -|`group_by` or `groupBy` -|`'nodes' \| 'parents' \| 'none'` - Group tasks by nodes or parent/child relationships + -_Default:_ `nodes` - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -[discrete] -=== termsEnum -*Stability:* beta -[source,ts] ----- -client.termsEnum({ - index: string | string[], - body: object -}) ----- -link:{ref}/search-terms-enum.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`body` -|`object` - field name, string which is the prefix expected in matching terms, timeout and size for max number of results - -|=== - -[discrete] -=== termvectors - -[source,ts] ----- -client.termvectors({ - index: string, - id: string, - type: string, - term_statistics: boolean, - field_statistics: boolean, - fields: string | string[], - offsets: boolean, - positions: boolean, - payloads: boolean, - preference: string, - routing: string, - realtime: boolean, - version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force', - body: object -}) ----- -link:{ref}/docs-termvectors.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The index in which the document resides. - -|`id` -|`string` - The id of the document, when not specified a doc param should be supplied. - -|`type` -|`string` - The type of the document. - -|`term_statistics` or `termStatistics` -|`boolean` - Specifies if total term frequency and document frequency should be returned. - -|`field_statistics` or `fieldStatistics` -|`boolean` - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. + -_Default:_ `true` - -|`fields` -|`string \| string[]` - A comma-separated list of fields to return. - -|`offsets` -|`boolean` - Specifies if term offsets should be returned. + -_Default:_ `true` - -|`positions` -|`boolean` - Specifies if term positions should be returned. + -_Default:_ `true` - -|`payloads` -|`boolean` - Specifies if term payloads should be returned. + -_Default:_ `true` - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random). - -|`routing` -|`string` - Specific routing value. - -|`realtime` -|`boolean` - Specifies if request is real-time as opposed to near-real-time (default: true). - -|`version` -|`number` - Explicit version number for concurrency control - -|`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type - -|`body` -|`object` - Define parameters and or supply a document to get termvectors for. See documentation. - -|=== - -[discrete] -=== textStructure.findStructure - -[source,ts] ----- -client.textStructure.findStructure({ - lines_to_sample: number, - line_merge_size_limit: number, - timeout: string, - charset: string, - format: 'ndjson' | 'xml' | 'delimited' | 'semi_structured_text', - has_header_row: boolean, - column_names: string | string[], - delimiter: string, - quote: string, - should_trim_fields: boolean, - grok_pattern: string, - timestamp_field: string, - timestamp_format: string, - explain: boolean, - body: object -}) ----- -link:{ref}/find-structure.html[Documentation] + -[cols=2*] -|=== -|`lines_to_sample` or `linesToSample` -|`number` - How many lines of the file should be included in the analysis + -_Default:_ `1000` - -|`line_merge_size_limit` or `lineMergeSizeLimit` -|`number` - Maximum number of characters permitted in a single message when lines are merged to create messages. + -_Default:_ `10000` - -|`timeout` -|`string` - Timeout after which the analysis will be aborted + -_Default:_ `25s` - -|`charset` -|`string` - Optional parameter to specify the character set of the file - -|`format` -|`'ndjson' \| 'xml' \| 'delimited' \| 'semi_structured_text'` - Optional parameter to specify the high level file format - -|`has_header_row` or `hasHeaderRow` -|`boolean` - Optional parameter to specify whether a delimited file includes the column names in its first row - -|`column_names` or `columnNames` -|`string \| string[]` - Optional parameter containing a comma separated list of the column names for a delimited file - -|`delimiter` -|`string` - Optional parameter to specify the delimiter character for a delimited file - must be a single character - -|`quote` -|`string` - Optional parameter to specify the quote character for a delimited file - must be a single character - -|`should_trim_fields` or `shouldTrimFields` -|`boolean` - Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them - -|`grok_pattern` or `grokPattern` -|`string` - Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file - -|`timestamp_field` or `timestampField` -|`string` - Optional parameter to specify the timestamp field in the file - -|`timestamp_format` or `timestampFormat` -|`string` - Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format - -|`explain` -|`boolean` - Whether to include a commentary on how the structure was derived - -|`body` -|`object` - The contents of the file to be analyzed - -|=== - -[discrete] -=== transform.deleteTransform - -[source,ts] ----- -client.transform.deleteTransform({ - transform_id: string, - force: boolean -}) ----- -link:{ref}/delete-transform.html[Documentation] + -[cols=2*] -|=== -|`transform_id` or `transformId` -|`string` - The id of the transform to delete - -|`force` -|`boolean` - When `true`, the transform is deleted regardless of its current state. The default value is `false`, meaning that the transform must be `stopped` before it can be deleted. - -|=== - -[discrete] -=== transform.getTransform - -[source,ts] ----- -client.transform.getTransform({ - transform_id: string, - from: number, - size: number, - allow_no_match: boolean, - exclude_generated: boolean -}) ----- -link:{ref}/get-transform.html[Documentation] + -[cols=2*] -|=== -|`transform_id` or `transformId` -|`string` - The id or comma delimited list of id expressions of the transforms to get, '_all' or '*' implies get all transforms - -|`from` -|`number` - skips a number of transform configs, defaults to 0 - -|`size` -|`number` - specifies a max number of transforms to get, defaults to 100 - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) - -|`exclude_generated` or `excludeGenerated` -|`boolean` - Omits fields that are illegal to set on transform PUT - -|=== - -[discrete] -=== transform.getTransformStats - -[source,ts] ----- -client.transform.getTransformStats({ - transform_id: string, - from: number, - size: number, - allow_no_match: boolean -}) ----- -link:{ref}/get-transform-stats.html[Documentation] + -[cols=2*] -|=== -|`transform_id` or `transformId` -|`string` - The id of the transform for which to get stats. '_all' or '*' implies all transforms - -|`from` -|`number` - skips a number of transform stats, defaults to 0 - -|`size` -|`number` - specifies a max number of transform stats to get, defaults to 100 - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) - -|=== - -[discrete] -=== transform.previewTransform - -[source,ts] ----- -client.transform.previewTransform({ - body: object -}) ----- -link:{ref}/preview-transform.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - The definition for the transform to preview - -|=== - -[discrete] -=== transform.putTransform - -[source,ts] ----- -client.transform.putTransform({ - transform_id: string, - defer_validation: boolean, - body: object -}) ----- -link:{ref}/put-transform.html[Documentation] + -[cols=2*] -|=== -|`transform_id` or `transformId` -|`string` - The id of the new transform. - -|`defer_validation` or `deferValidation` -|`boolean` - If validations should be deferred until transform starts, defaults to false. - -|`body` -|`object` - The transform definition - -|=== - -[discrete] -=== transform.startTransform - -[source,ts] ----- -client.transform.startTransform({ - transform_id: string, - timeout: string -}) ----- -link:{ref}/start-transform.html[Documentation] + -[cols=2*] -|=== -|`transform_id` or `transformId` -|`string` - The id of the transform to start - -|`timeout` -|`string` - Controls the time to wait for the transform to start - -|=== - -[discrete] -=== transform.stopTransform - -[source,ts] ----- -client.transform.stopTransform({ - transform_id: string, - force: boolean, - wait_for_completion: boolean, - timeout: string, - allow_no_match: boolean, - wait_for_checkpoint: boolean -}) ----- -link:{ref}/stop-transform.html[Documentation] + -[cols=2*] -|=== -|`transform_id` or `transformId` -|`string` - The id of the transform to stop - -|`force` -|`boolean` - Whether to force stop a failed transform or not. Default to false - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Whether to wait for the transform to fully stop before returning or not. Default to false - -|`timeout` -|`string` - Controls the time to wait until the transform has stopped. Default to 30 seconds - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) - -|`wait_for_checkpoint` or `waitForCheckpoint` -|`boolean` - Whether to wait for the transform to reach a checkpoint before stopping. Default to false - -|=== - -[discrete] -=== transform.updateTransform - -[source,ts] ----- -client.transform.updateTransform({ - transform_id: string, - defer_validation: boolean, - body: object -}) ----- -link:{ref}/update-transform.html[Documentation] + -[cols=2*] -|=== -|`transform_id` or `transformId` -|`string` - The id of the transform. - -|`defer_validation` or `deferValidation` -|`boolean` - If validations should be deferred until transform starts, defaults to false. - -|`body` -|`object` - The update transform definition - -|=== - -[discrete] -=== update - -[source,ts] ----- -client.update({ - id: string, - index: string, - type: string, - wait_for_active_shards: string, - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - lang: string, - refresh: 'true' | 'false' | 'wait_for', - retry_on_conflict: number, - routing: string, - timeout: string, - if_seq_no: number, - if_primary_term: number, - require_alias: boolean, - body: object -}) ----- -link:{ref}/docs-update.html[Documentation] + -{jsclient}/update_examples.html[Code Example] + -[cols=2*] -|=== -|`id` -|`string` - Document ID - -|`index` -|`string` - The name of the index - -|`type` -|`string` - The type of the document + - -WARNING: This parameter has been deprecated. - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`lang` -|`string` - The script language (default: painless) - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. - -|`retry_on_conflict` or `retryOnConflict` -|`number` - Specify how many times should the operation be retried when a conflict occurs (default: 0) - -|`routing` -|`string` - Specific routing value - -|`timeout` -|`string` - Explicit operation timeout - -|`if_seq_no` or `ifSeqNo` -|`number` - only perform the update operation if the last operation that has changed the document has the specified sequence number - -|`if_primary_term` or `ifPrimaryTerm` -|`number` - only perform the update operation if the last operation that has changed the document has the specified primary term - -|`require_alias` or `requireAlias` -|`boolean` - When true, requires destination is an alias. Default is false - -|`body` -|`object` - The request definition requires either `script` or partial `doc` - -|=== - -[discrete] -=== updateByQuery - -[source,ts] ----- -client.updateByQuery({ - index: string | string[], - type: string | string[], - analyzer: string, - analyze_wildcard: boolean, - default_operator: 'AND' | 'OR', - df: string, - from: number, - ignore_unavailable: boolean, - allow_no_indices: boolean, - conflicts: 'abort' | 'proceed', - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - lenient: boolean, - pipeline: string, - preference: string, - q: string, - routing: string | string[], - scroll: string, - search_type: 'query_then_fetch' | 'dfs_query_then_fetch', - search_timeout: string, - size: number, - max_docs: number, - sort: string | string[], - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - terminate_after: number, - stats: string | string[], - version: boolean, - version_type: boolean, - request_cache: boolean, - refresh: boolean, - timeout: string, - wait_for_active_shards: string, - scroll_size: number, - wait_for_completion: boolean, - requests_per_second: number, - slices: number|string, - body: object -}) ----- -link:{ref}/docs-update-by-query.html[Documentation] + -{jsclient}/update_by_query_examples.html[Code Example] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`type` -|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types - -|`analyzer` -|`string` - The analyzer to use for the query string - -|`analyze_wildcard` or `analyzeWildcard` -|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) - -|`default_operator` or `defaultOperator` -|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + -_Default:_ `OR` - -|`df` -|`string` - The field to use as default where no field prefix is given in the query string - -|`from` -|`number` - Starting offset (default: 0) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`conflicts` -|`'abort' \| 'proceed'` - What to do when the update by query hits version conflicts? + -_Default:_ `abort` - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`lenient` -|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - -|`pipeline` -|`string` - Ingest pipeline to set on index requests made by this action. (default: none) - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`q` -|`string` - Query in the Lucene query string syntax - -|`routing` -|`string \| string[]` - A comma-separated list of specific routing values - -|`scroll` -|`string` - Specify how long a consistent view of the index should be maintained for scrolled search - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type - -|`search_timeout` or `searchTimeout` -|`string` - Explicit timeout for each search request. Defaults to no timeout. - -|`size` -|`number` - Deprecated, please use `max_docs` instead - -|`max_docs` or `maxDocs` -|`number` - Maximum number of documents to process (default: all documents) - -|`sort` -|`string \| string[]` - A comma-separated list of : pairs - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`terminate_after` or `terminateAfter` -|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. - -|`stats` -|`string \| string[]` - Specific 'tag' of the request for logging and statistical purposes - -|`version` -|`boolean` - Specify whether to return document version as part of a hit - -|`version_type` or `versionType` -|`boolean` - Should the document increment the version number (internal) on hit or not (reindex) - -|`request_cache` or `requestCache` -|`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting - -|`refresh` -|`boolean` - Should the affected indexes be refreshed? - -|`timeout` -|`string` - Time each individual bulk request should wait for shards that are unavailable. + -_Default:_ `1m` - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - -|`scroll_size` or `scrollSize` -|`number` - Size on the scroll request powering the update by query + -_Default:_ `100` - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should the request should block until the update by query operation is complete. + -_Default:_ `true` - -|`requests_per_second` or `requestsPerSecond` -|`number` - The throttle to set on this request in sub-requests per second. -1 means no throttle. - -|`slices` -|`number\|string` - The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. + -_Default:_ `1` - -|`body` -|`object` - The search definition using the Query DSL - -|=== - -[discrete] -=== updateByQueryRethrottle - -[source,ts] ----- -client.updateByQueryRethrottle({ - task_id: string, - requests_per_second: number -}) ----- -link:{ref}/docs-update-by-query.html[Documentation] + -[cols=2*] -|=== -|`task_id` or `taskId` -|`string` - The task id to rethrottle - -|`requests_per_second` or `requestsPerSecond` -|`number` - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. - -|=== - -[discrete] -=== watcher.ackWatch - -[source,ts] ----- -client.watcher.ackWatch({ - watch_id: string, - action_id: string | string[] -}) ----- -link:{ref}/watcher-api-ack-watch.html[Documentation] + -[cols=2*] -|=== -|`watch_id` or `watchId` -|`string` - Watch ID - -|`action_id` or `actionId` -|`string \| string[]` - A comma-separated list of the action ids to be acked - -|=== - -[discrete] -=== watcher.activateWatch - -[source,ts] ----- -client.watcher.activateWatch({ - watch_id: string -}) ----- -link:{ref}/watcher-api-activate-watch.html[Documentation] + -[cols=2*] -|=== -|`watch_id` or `watchId` -|`string` - Watch ID - -|=== - -[discrete] -=== watcher.deactivateWatch - -[source,ts] ----- -client.watcher.deactivateWatch({ - watch_id: string -}) ----- -link:{ref}/watcher-api-deactivate-watch.html[Documentation] + -[cols=2*] -|=== -|`watch_id` or `watchId` -|`string` - Watch ID - -|=== - -[discrete] -=== watcher.deleteWatch - -[source,ts] ----- -client.watcher.deleteWatch({ - id: string -}) ----- -link:{ref}/watcher-api-delete-watch.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - Watch ID - -|=== - -[discrete] -=== watcher.executeWatch - -[source,ts] ----- -client.watcher.executeWatch({ - id: string, - debug: boolean, - body: object -}) ----- -link:{ref}/watcher-api-execute-watch.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - Watch ID - -|`debug` -|`boolean` - indicates whether the watch should execute in debug mode - -|`body` -|`object` - Execution control - -|=== - -[discrete] -=== watcher.getWatch - -[source,ts] ----- -client.watcher.getWatch({ - id: string -}) ----- -link:{ref}/watcher-api-get-watch.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - Watch ID - -|=== - -[discrete] -=== watcher.putWatch - -[source,ts] ----- -client.watcher.putWatch({ - id: string, - active: boolean, - version: number, - if_seq_no: number, - if_primary_term: number, - body: object -}) ----- -link:{ref}/watcher-api-put-watch.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - Watch ID - -|`active` -|`boolean` - Specify whether the watch is in/active by default - -|`version` -|`number` - Explicit version number for concurrency control - -|`if_seq_no` or `ifSeqNo` -|`number` - only update the watch if the last operation that has changed the watch has the specified sequence number - -|`if_primary_term` or `ifPrimaryTerm` -|`number` - only update the watch if the last operation that has changed the watch has the specified primary term - -|`body` -|`object` - The watch - -|=== - -[discrete] -=== watcher.queryWatches - -[source,ts] ----- -client.watcher.queryWatches({ - body: object -}) ----- -link:{ref}/watcher-api-query-watches.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - From, size, query, sort and search_after - -|=== - -[discrete] -=== watcher.start - -[source,ts] ----- -client.watcher.start() ----- -link:{ref}/watcher-api-start.html[Documentation] + - - -[discrete] -=== watcher.stats - -[source,ts] ----- -client.watcher.stats({ - metric: string | string[], - emit_stacktraces: boolean -}) ----- -link:{ref}/watcher-api-stats.html[Documentation] + -[cols=2*] -|=== -|`metric` -|`string \| string[]` - Controls what additional stat metrics should be include in the response - -|`emit_stacktraces` or `emitStacktraces` -|`boolean` - Emits stack traces of currently running watches - -|=== - -[discrete] -=== watcher.stop - -[source,ts] ----- -client.watcher.stop() ----- -link:{ref}/watcher-api-stop.html[Documentation] + - - -[discrete] -=== xpack.info - -[source,ts] ----- -client.xpack.info({ - categories: string | string[], - accept_enterprise: boolean -}) ----- -link:{ref}/info-api.html[Documentation] + -[cols=2*] -|=== -|`categories` -|`string \| string[]` - Comma-separated list of info categories. Can be any of: build, license, features - -|`accept_enterprise` or `acceptEnterprise` -|`boolean` - If an enterprise license is installed, return the type and mode as 'enterprise' (default: false) - -|=== - -[discrete] -=== xpack.usage - -[source,ts] ----- -client.xpack.usage({ - master_timeout: string -}) ----- -link:{ref}/usage-api.html[Documentation] + -[cols=2*] -|=== -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for watch write operation - -|=== diff --git a/docs/testing.asciidoc b/docs/testing.asciidoc deleted file mode 100644 index af9fcf25f..000000000 --- a/docs/testing.asciidoc +++ /dev/null @@ -1,157 +0,0 @@ -[[client-testing]] -=== Testing - -Testing is one of the most important parts of developing an application. -The client is very flexible when it comes to testing and is compatible with -most testing frameworks (such as https://www.npmjs.com/package/ava[`ava`], -which is used in the examples below). - -If you are using this client, you are most likely working with {es}, and one of -the first issues you face is how to test your application. A perfectly valid -solution is to use the real {es} instance for testing your application, but you -would be doing an integration test, while you want a unit test. There are many -ways to solve this problem, you could create the database with Docker, or use an -in-memory compatible one, but if you are writing unit tests that can be easily -parallelized this becomes quite uncomfortable. A different way of improving your -testing experience while doing unit tests is to use a mock. - -The client is designed to be easy to extend and adapt to your needs. Thanks to -its internal architecture it allows you to change some specific components while -keeping the rest of it working as usual. Each {es} official client is composed -of the following components: - -* `API layer`: every {es} API that you can call. -* `Transport`: a component that takes care of preparing a request before sending - it and handling all the retry and sniffing strategies. -* `ConnectionPool`: {es} is a cluster and might have multiple nodes, the - `ConnectionPool` takes care of them. -* `Serializer`: A class with all the serialization strategies, from the basic - JSON to the new line delimited JSON. -* `Connection`: The actual HTTP library. - -The best way to mock {es} with the official clients is to replace the -`Connection` component since it has very few responsibilities and it does not -interact with other internal components other than getting requests and -returning responses. - - -[discrete] -==== `@elastic/elasticsearch-mock` - -Writing each time a mock for your test can be annoying and error-prone, so we -have built a simple yet powerful mocking library specifically designed for this -client, and you can install it with the following command: - -[source,sh] ----- -npm install @elastic/elasticsearch-mock --save-dev ----- - -With this library you can create custom mocks for any request you can send to -{es}. It offers a simple and intuitive API and it mocks only the HTTP layer, -leaving the rest of the client working as usual. - -Before showing all of its features, and what you can do with it, let’s see an -example: - -[source,js] ----- -const { Client } = require('@elastic/elasticsearch') -const Mock = require('@elastic/elasticsearch-mock') - -const mock = new Mock() -const client = new Client({ - node: 'http://localhost:9200', - Connection: mock.getConnection() -}) - -mock.add({ - method: 'GET', - path: '/' -}, () => { - return { status: 'ok' } -}) - -client.info(console.log) ----- - -As you can see it works closely with the client itself, once you have created a -new instance of the mock library you just need to call the mock.getConnection() -method and pass its result to the Connection option of the client. From now on, -every request is handled by the mock library, and the HTTP layer will never be -touched. As a result, your test is significantly faster and you are able to -easily parallelize them! - -The library allows you to write both “strict” and “loose” mocks, which means -that you can write a mock that handles a very specific request or be looser and -handle a group of request, let’s see this in action: - -[source,js] ----- -mock.add({ - method: 'POST', - path: '/indexName/_search' -}, () => { - return { - hits: { - total: { value: 1, relation: 'eq' }, - hits: [{ _source: { baz: 'faz' } }] - } - } -}) - -mock.add({ - method: 'POST', - path: '/indexName/_search', - body: { query: { match: { foo: 'bar' } } } -}, () => { - return { - hits: { - total: { value: 0, relation: 'eq' }, - hits: [] - } - } -}) ----- - -In the example above, every search request gets the first response, while every -search request that uses the query described in the second mock gets the second -response. - -You can also specify dynamic paths: - -[source,js] ----- -mock.add({ - method: 'GET', - path: '/:index/_count' -}, () => { - return { count: 42 } -}) - -client.count({ index: 'foo' }, console.log) // => { count: 42 } -client.count({ index: 'bar' }, console.log) // => { count: 42 } ----- - -And wildcards are supported as well. - -Another very interesting use case is the ability to create a test that randomly -fails to see how your code reacts to failures: - -[source,js] ----- -mock.add({ - method: 'GET', - path: '/:index/_count' -}, () => { - if (Math.random() > 0.8) { - return ResponseError({ body: {}, statusCode: 500 }) - } else { - return { count: 42 } - } -}) ----- - -We have seen how simple is mocking {es} and testing your application, you can -find many more features and examples in the -https://github.com/elastic/elasticsearch-js-mock[module documentation]. \ No newline at end of file diff --git a/docs/transport.asciidoc b/docs/transport.asciidoc deleted file mode 100644 index f4fc722ce..000000000 --- a/docs/transport.asciidoc +++ /dev/null @@ -1,34 +0,0 @@ -[[transport]] -=== Transport - -This class is responsible for performing the request to {es} and handling -errors, it also handles sniffing. - -[source,js] ----- -const { Client, Transport } = require('@elastic/elasticsearch') - -class MyTransport extends Transport { - request (params, options, callback) { - // your code - } -} - -const client = new Client({ - Transport: MyTransport -}) ----- - -Sometimes you need to inject a small snippet of your code and then continue to -use the usual client code. In such cases, call `super.method`: - -[source,js] ----- -class MyTransport extends Transport { - request (params, options, callback) { - // your code - return super.request(params, options, callback) - } -} ----- - diff --git a/docs/typescript.asciidoc b/docs/typescript.asciidoc deleted file mode 100644 index 177676a91..000000000 --- a/docs/typescript.asciidoc +++ /dev/null @@ -1,277 +0,0 @@ -[[typescript]] -=== TypeScript support - -The client offers a first-class support for TypeScript, shipping a complete set -of type definitions of Elasticsearch's API surface. - - -NOTE: If you are using TypeScript you need to use _snake_case_ style to define -the API parameters instead of _camelCase_. - -Currently the client exposes two type definitions, the legacy one, which is the default -and the new one, which will be the default in the next major. -We strongly recommend to migrate to the new one as soon as possible, as the new types -are offering a vastly improved developer experience and guarantee you that your code -will always be in sync with the latest Elasticsearch features. - -[discrete] -==== New type definitions - -The new type definition is more advanced compared to the legacy one. In the legacy -type definitions you were expected to configure via generics both request and response -bodies. The new type definitions comes with a complete type definition for every -Elasticsearch endpoint. - -For example: - -[source,ts] ----- -// legacy definitions -const response = await client.search, SearchBody>({ - index: 'test', - body: { - query: { - match: { foo: 'bar' } - } - } -}) - -// new definitions -const response = await client.search({ - index: 'test', - body: { - query: { - match: { foo: 'bar' } - } - } -}) ----- - -The types are not 100% complete yet. Some APIs are missing (the newest ones, e.g. EQL), -and others may contain some errors, but we are continuously pushing fixes & improvements. - -[discrete] -==== Request & Response types - -Once you migrate to the new types, those are automatically integrated into the Elasticsearch client, you will get them out of the box. -If everything works, meaning that you won’t get compiler errors, you are good to go! -The types are already correct, and there is nothing more to do. - -If a type is incorrect, you should add a comment `// @ts-expect-error @elastic/elasticsearch` -telling TypeScript that you are aware of the warning and you would like to temporarily suppress it. -In this way, your code will compile until the type is fixed, and when it happens, you’ll only need to remove the -`// @ts-expect-error @elastic/elasticsearch` comment (TypeScript will let you know when it is time). -Finally, if the type you need is missing, you’ll see that the client method returns (or defines as a parameter) -a `TODO` type, which accepts any object. - -Open an issue in the client repository letting us know if you encounter any problem! - -If needed you can import the request and response types. - -[source,ts] ----- -import { Client, estypes } from '@elastic/elasticsearch' -import type { Client as NewTypes } from '@elastic/elasticsearch/api/new' - -// @ts-expect-error @elastic/elasticsearch -const client: NewTypes = new Client({ - node: 'http://localhost:9200' -}) - -interface Source { - foo: string -} - -const request: estypes.IndexRequest = { - index: 'test', - body: { foo: 'bar' } -} - -await client.index(request) ----- - -[discrete] -===== How to migrate to the new type definitions - -Since the new type definitions can be considered a breaking change we couldn't add the directly to the client. -Following you will find a snippet that shows you how to override the default types with the new ones. - -[source,ts] ----- -import { Client } from '@elastic/elasticsearch' -import type { Client as NewTypes } from '@elastic/elasticsearch/api/new' - -// @ts-expect-error @elastic/elasticsearch -const client: NewTypes = new Client({ - node: 'http://localhost:9200' -}) - -interface Source { - foo: string -} - -// try the new code completion when building a query! -const response = await client.search({ - index: 'test', - body: { - query: { - match_all: {} - } - } -}) - -// try the new code completion when traversing a response! -const results = response.body.hits.hits.map(hit => hit._source) -// results type will be `Source[]` -console.log(results) ----- - -[discrete] -==== Legacy type definitions - -By default event API uses -https://www.typescriptlang.org/docs/handbook/generics.html[generics] to specify -the requests and response bodies and the `meta.context`. Currently, we can't -provide those definitions, but we are working to improve this situation. - -You can find a partial definition of the request types by importing -`RequestParams`, which is used by default in the client and accepts a body (when -needed) as a generic to provide a better specification. - -The body defaults to `RequestBody` and `RequestNDBody`, which are defined as -follows: - -[source,ts] ----- -type RequestBody> = T | string | Buffer | ReadableStream -type RequestNDBody[]> = T | string | string[] | Buffer | ReadableStream ----- - -You can specify the response and request body in each API as follows: - -[source,ts] ----- -const response = await client.search({ - index: 'test', - body: { - query: { - match: { foo: 'bar' } - } - } -}) - -console.log(response.body) ----- - -You don't have to specify all the generics, but the order must be respected. - - -[discrete] -===== A complete example - -[source,ts] ----- -import { - Client, - // Object that contains the type definitions of every API method - RequestParams, - // Interface of the generic API response - ApiResponse, -} from '@elastic/elasticsearch' - -const client = new Client({ node: 'http://localhost:9200' }) - -// Define the type of the body for the Search request -interface SearchBody { - query: { - match: { foo: string } - } -} - -// Complete definition of the Search response -interface ShardsResponse { - total: number; - successful: number; - failed: number; - skipped: number; -} - -interface Explanation { - value: number; - description: string; - details: Explanation[]; -} - -interface SearchResponse { - took: number; - timed_out: boolean; - _scroll_id?: string; - _shards: ShardsResponse; - hits: { - total: number; - max_score: number; - hits: Array<{ - _index: string; - _type: string; - _id: string; - _score: number; - _source: T; - _version?: number; - _explanation?: Explanation; - fields?: any; - highlight?: any; - inner_hits?: any; - matched_queries?: string[]; - sort?: string[]; - }>; - }; - aggregations?: any; -} - -// Define the interface of the source object -interface Source { - foo: string -} - -async function run () { - // All of the examples below are valid code, by default, - // the request body will be `RequestBody` and response will be `Record`. - const response = await client.search({ - index: 'test', - body: { - query: { - match: { foo: 'bar' } - } - } - }) - // body here is `ResponseBody` - console.log(response.body) - - // The first generic is the response body - const response = await client.search>({ - index: 'test', - // Here the body must follow the `RequestBody` interface - body: { - query: { - match: { foo: 'bar' } - } - } - }) - // body here is `SearchResponse` - console.log(response.body) - - const response = await client.search, SearchBody>({ - index: 'test', - // Here the body must follow the `SearchBody` interface - body: { - query: { - match: { foo: 'bar' } - } - } - }) - // body here is `SearchResponse` - console.log(response.body) -} - -run().catch(console.log) -----