Compare commits
18 Commits
georgewall
...
v8.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d623ada4d | |||
| cc770a9031 | |||
| e1790135c6 | |||
| 820ed3e3e0 | |||
| 64ed0ecb61 | |||
| c51560e5c8 | |||
| e3a791b10f | |||
| 6392ee3a40 | |||
| 40eb32f884 | |||
| b648f7cdc5 | |||
| 63073e952c | |||
| 66723ee8c9 | |||
| 0817e3f884 | |||
| 3286101891 | |||
| 21804dd7e3 | |||
| d279b29d29 | |||
| 3e6b02b504 | |||
| 84d8b68007 |
@ -7,7 +7,7 @@
|
||||
parameters:
|
||||
- string:
|
||||
name: branch_specifier
|
||||
default: refs/heads8.0
|
||||
default: refs/heads/8.0
|
||||
description: the Git branch specifier to build (<branchName>, <tagName>,
|
||||
<commitId>, etc.)
|
||||
triggers:
|
||||
|
||||
15
.ci/jobs/elastic+elasticsearch-js+8.1.yml
Normal file
15
.ci/jobs/elastic+elasticsearch-js+8.1.yml
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
- job:
|
||||
name: elastic+elasticsearch-js+8.1
|
||||
display-name: 'elastic / elasticsearch-js # 8.1'
|
||||
description: Testing the elasticsearch-js 8.1 branch.
|
||||
junit_results: "*-junit.xml"
|
||||
parameters:
|
||||
- string:
|
||||
name: branch_specifier
|
||||
default: refs/heads/8.1
|
||||
description: the Git branch specifier to build (<branchName>, <tagName>,
|
||||
<commitId>, etc.)
|
||||
triggers:
|
||||
- github
|
||||
- timed: 'H */12 * * *'
|
||||
75
README.md
75
README.md
@ -45,6 +45,7 @@ of `^7.10.0`).
|
||||
| --------------- |------------------| ---------------------- |
|
||||
| `8.x` | `December 2019` | `7.11` (early 2021) |
|
||||
| `10.x` | `April 2021` | `7.12` (mid 2021) |
|
||||
| `12.x` | `April 2022` | `8.2` (early 2022) |
|
||||
|
||||
### Compatibility
|
||||
|
||||
@ -53,7 +54,7 @@ Elasticsearch language clients are only backwards compatible with default distri
|
||||
|
||||
| Elasticsearch Version | Client Version |
|
||||
| --------------------- |----------------|
|
||||
| `main` | `main` |
|
||||
| `8.x` | `8.x` |
|
||||
| `7.x` | `7.x` |
|
||||
| `6.x` | `6.x` |
|
||||
| `5.x` | `5.x` |
|
||||
@ -74,11 +75,9 @@ We recommend that you write a lightweight proxy that uses this client instead, y
|
||||
- [Usage](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-connecting.html#client-usage)
|
||||
- [Client configuration](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-configuration.html)
|
||||
- [API reference](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html)
|
||||
- [Breaking changes coming from the old client](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/breaking-changes.html)
|
||||
- [Authentication](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-connecting.html#authentication)
|
||||
- [Observability](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/observability.html)
|
||||
- [Creating a child client](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/child.html)
|
||||
- [Extend the client](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/extend.html)
|
||||
- [Client helpers](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-helpers.html)
|
||||
- [Typescript support](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/typescript.html)
|
||||
- [Testing](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-testing.html)
|
||||
@ -86,48 +85,6 @@ We recommend that you write a lightweight proxy that uses this client instead, y
|
||||
|
||||
## Quick start
|
||||
|
||||
First of all, require the client and initialize it:
|
||||
```js
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({ node: 'http://localhost:9200' })
|
||||
```
|
||||
|
||||
You can use both the callback-style API and the promise-style API, both behave the same way.
|
||||
```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:
|
||||
```ts
|
||||
{
|
||||
body: object | boolean
|
||||
statusCode: number
|
||||
headers: object
|
||||
warnings: [string]
|
||||
meta: object
|
||||
}
|
||||
```
|
||||
|
||||
Let's see a complete example!
|
||||
```js
|
||||
'use strict'
|
||||
|
||||
@ -138,8 +95,7 @@ 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 Elasticsearch ≤ 6
|
||||
body: {
|
||||
document: {
|
||||
character: 'Ned Stark',
|
||||
quote: 'Winter is coming.'
|
||||
}
|
||||
@ -147,8 +103,7 @@ async function run () {
|
||||
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
// type: '_doc', // uncomment this line if you are using Elasticsearch ≤ 6
|
||||
body: {
|
||||
document: {
|
||||
character: 'Daenerys Targaryen',
|
||||
quote: 'I am the blood of the dragon.'
|
||||
}
|
||||
@ -156,8 +111,7 @@ async function run () {
|
||||
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
// type: '_doc', // uncomment this line if you are using Elasticsearch ≤ 6
|
||||
body: {
|
||||
document: {
|
||||
character: 'Tyrion Lannister',
|
||||
quote: 'A mind needs books like a sword needs a whetstone.'
|
||||
}
|
||||
@ -168,17 +122,14 @@ async function run () {
|
||||
await client.indices.refresh({ index: 'game-of-thrones' })
|
||||
|
||||
// Let's search!
|
||||
const { body } = await client.search({
|
||||
const result= await client.search({
|
||||
index: 'game-of-thrones',
|
||||
// type: '_doc', // uncomment this line if you are using Elasticsearch ≤ 6
|
||||
body: {
|
||||
query: {
|
||||
match: { quote: 'winter' }
|
||||
}
|
||||
query: {
|
||||
match: { quote: 'winter' }
|
||||
}
|
||||
})
|
||||
|
||||
console.log(body.hits.hits)
|
||||
console.log(result.hits.hits)
|
||||
}
|
||||
|
||||
run().catch(console.log)
|
||||
@ -211,13 +162,13 @@ 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)
|
||||
client6.info().then(console.log, console.log)
|
||||
client7.info().then(console.log, console.log)
|
||||
```
|
||||
|
||||
Finally, if you want to install the client for the next version of Elasticsearch *(the one that lives in Elasticsearch’s master branch)*, you can use the following command:
|
||||
Finally, if you want to install the client for the next version of Elasticsearch *(the one that lives in Elasticsearch’s main branch)*, you can use the following command:
|
||||
```sh
|
||||
npm install esmaster@github:elastic/elasticsearch-js
|
||||
npm install esmain@github:elastic/elasticsearch-js
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
@ -45,9 +45,9 @@ is performed here, this means that if you want to swap the default HTTP client
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client, Connection } = require('@elastic/elasticsearch')
|
||||
const { Client, BaseConnection } = require('@elastic/elasticsearch')
|
||||
|
||||
class MyConnection extends Connection {
|
||||
class MyConnection extends BaseConnection {
|
||||
request (params, callback) {
|
||||
// your code
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ Or it can be an object (or an array of objects) that represents the node:
|
||||
----
|
||||
node: {
|
||||
url: new URL('http://localhost:9200'),
|
||||
ssl: 'ssl options',
|
||||
tls: 'tls options',
|
||||
agent: 'http agent options',
|
||||
id: 'custom node id',
|
||||
headers: { 'custom': 'headers' }
|
||||
@ -48,8 +48,7 @@ node: {
|
||||
|`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. +
|
||||
See <<authentication,Authentication>> for more details. +
|
||||
_Default:_ `null`
|
||||
|
||||
Basic authentication:
|
||||
@ -118,8 +117,8 @@ _Default:_ `false`
|
||||
_Options:_ `'gzip'`, `false` +
|
||||
_Default:_ `false`
|
||||
|
||||
|`ssl`
|
||||
|`http.SecureContextOptions` - ssl https://nodejs.org/api/tls.html[configuraton]. +
|
||||
|`tls`
|
||||
|`http.SecureContextOptions` - tls https://nodejs.org/api/tls.html[configuraton]. +
|
||||
_Default:_ `null`
|
||||
|
||||
|`proxy`
|
||||
@ -267,24 +266,4 @@ _Default:_ `null`
|
||||
|`number` - When configured, it verifies that the compressed response size is lower than the configured number, if it's higher it will abort the request. It cannot be higher than buffer.constants.MAX_LENTGH +
|
||||
_Default:_ `null`
|
||||
|
||||
|===
|
||||
|
||||
[discrete]
|
||||
==== Performances considerations
|
||||
|
||||
By default, the client will protection 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.
|
||||
|
||||
While it's good to be safe, you should know that security always comes with a cost.
|
||||
With big enough payloads, this security check could causea drop in the overall performances,
|
||||
which might be a problem for your application.
|
||||
If you know you can trust the data stored in Elasticsearch, you can safely disable this check.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const client = new Client({
|
||||
disablePrototypePoisoningProtection: true
|
||||
})
|
||||
----
|
||||
|===
|
||||
@ -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)
|
||||
}
|
||||
})
|
||||
----
|
||||
355
docs/changelog.asciidoc
Normal file
355
docs/changelog.asciidoc
Normal file
@ -0,0 +1,355 @@
|
||||
[[changelog-client]]
|
||||
== Release notes
|
||||
|
||||
[discrete]
|
||||
=== 8.1.0
|
||||
|
||||
[discrete]
|
||||
==== Features
|
||||
|
||||
[discrete]
|
||||
===== Support for Elasticsearch `v8.1`
|
||||
|
||||
You can find all the API changes
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/8.1/release-notes-8.1.0.html[here].
|
||||
|
||||
[discrete]
|
||||
===== Export SniffingTransport https://github.com/elastic/elasticsearch-js/pull/1653[#1653]
|
||||
|
||||
Now the client exports the SniffingTransport class.
|
||||
|
||||
[discrete]
|
||||
==== Fixes
|
||||
|
||||
[discrete]
|
||||
===== Cleanup abort listener https://github.com/elastic/elastic-transport-js/pull/42[transport/#42]
|
||||
|
||||
The legacy http client was not cleaning up the abort listener, which could cause a memory leak.
|
||||
|
||||
[discrete]
|
||||
===== Improve undici performances https://github.com/elastic/elastic-transport-js/pull/41[transport/#41]
|
||||
|
||||
Improve the stream body collection and keep alive timeout.
|
||||
|
||||
[discrete]
|
||||
=== 8.0.0
|
||||
|
||||
[discrete]
|
||||
==== Features
|
||||
|
||||
[discrete]
|
||||
===== Support for Elasticsearch `v8.0`
|
||||
|
||||
You can find all the API changes
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/8.0/release-notes-8.0.0.html[here].
|
||||
|
||||
[discrete]
|
||||
===== Drop old typescript definitions
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Medium*
|
||||
|
||||
The current TypeScript definitions will be removed from the client, and the new definitions, which contain request and response definitions as well will be shipped by default.
|
||||
|
||||
[discrete]
|
||||
===== Drop callback-style API
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Large*
|
||||
|
||||
Maintaining both API styles is not a problem per se, but it makes error handling more convoluted due to async stack traces.
|
||||
Moving to a full-promise API will solve this issue.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
// callback-style api
|
||||
client.search({ params }, { options }, (err, result) => {
|
||||
console.log(err || result)
|
||||
})
|
||||
|
||||
// promise-style api
|
||||
client.search({ params }, { options })
|
||||
.then(console.log)
|
||||
.catch(console.log)
|
||||
|
||||
// async-style (sugar syntax on top of promises)
|
||||
const response = await client.search({ params }, { options })
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
If you are already using the promise-style API, this won't be a breaking change for you.
|
||||
|
||||
[discrete]
|
||||
===== Remove the current abort API and use the new AbortController standard
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small*
|
||||
|
||||
The old abort API makes sense for callbacks but it's annoying to use with promises
|
||||
|
||||
[source,js]
|
||||
----
|
||||
// callback-style api
|
||||
const request = client.search({ params }, { options }, (err, result) => {
|
||||
console.log(err) // RequestAbortedError
|
||||
})
|
||||
|
||||
request.abort()
|
||||
|
||||
// promise-style api
|
||||
const promise = client.search({ params }, { options })
|
||||
|
||||
promise
|
||||
.then(console.log)
|
||||
.catch(console.log) // RequestAbortedError
|
||||
|
||||
promise.abort()
|
||||
----
|
||||
|
||||
Node v12 has added the standard https://nodejs.org/api/globals.html#globals_class_abortcontroller[`AbortController`] API which is designed to work well with both callbacks and promises.
|
||||
[source,js]
|
||||
----
|
||||
const ac = new AbortController()
|
||||
client.search({ params }, { signal: ac.signal })
|
||||
.then(console.log)
|
||||
.catch(console.log) // RequestAbortedError
|
||||
|
||||
ac.abort()
|
||||
----
|
||||
|
||||
[discrete]
|
||||
===== Remove the body key from the request
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small*
|
||||
|
||||
Thanks to the new types we are developing now we know exactly where a parameter should go.
|
||||
The client API leaks HTTP-related notions in many places, and removing them would definitely improve the DX.
|
||||
|
||||
This could be a rather big breaking change, so a double solution could be used during the 8.x lifecycle. (accepting body keys without them being wrapped in the body as well as the current solution).
|
||||
|
||||
[source,js]
|
||||
----
|
||||
// from
|
||||
const response = await client.search({
|
||||
index: 'test',
|
||||
body: {
|
||||
query: {
|
||||
match_all: {}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// to
|
||||
const response = await client.search({
|
||||
index: 'test',
|
||||
query: {
|
||||
match_all: {}
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
[discrete]
|
||||
===== Migrate to new separate transport
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small to none*
|
||||
|
||||
The separated transport has been rewritten in TypeScript and has already dropped the callback style API.
|
||||
Given that now is separated, most of the Elasticsearch specific concepts have been removed, and the client will likely need to extend parts of it for reintroducing them.
|
||||
If you weren't extending the internals of the client, this won't be a breaking change for you.
|
||||
|
||||
[discrete]
|
||||
===== The returned value of API calls is the body and not the HTTP related keys
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small*
|
||||
|
||||
The client API leaks HTTP-related notions in many places, and removing them would definitely improve the DX.
|
||||
The client will expose a new request-specific option to still get the full response details.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
// from
|
||||
const response = await client.search({
|
||||
index: 'test',
|
||||
body: {
|
||||
query: {
|
||||
match_all: {}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response) // { body: SearchResponse, statusCode: number, headers: object, warnings: array }
|
||||
|
||||
// to
|
||||
const response = await client.search({
|
||||
index: 'test',
|
||||
query: {
|
||||
match_all: {}
|
||||
}
|
||||
})
|
||||
console.log(response) // SearchResponse
|
||||
|
||||
// with a bit of TypeScript and JavaScript magic...
|
||||
const response = await client.search({
|
||||
index: 'test',
|
||||
query: {
|
||||
match_all: {}
|
||||
}
|
||||
}, {
|
||||
meta: true
|
||||
})
|
||||
console.log(response) // { body: SearchResponse, statusCode: number, headers: object, warnings: array }
|
||||
----
|
||||
|
||||
[discrete]
|
||||
===== Use a weighted connection pool
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small to none*
|
||||
|
||||
Move from the current cluster connection pool to a weight-based implementation.
|
||||
This new implementation offers better performances and runs less code in the background, the old connection pool can still be used.
|
||||
If you weren't extending the internals of the client, this won't be a breaking change for you.
|
||||
|
||||
[discrete]
|
||||
===== Migrate to the "undici" http client
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small to none*
|
||||
|
||||
By default, the HTTP client will no longer be the default Node.js HTTP client, but https://github.com/nodejs/undici[undici] instead.
|
||||
Undici is a brand new HTTP client written from scratch, it offers vastly improved performances and has better support for promises.
|
||||
Furthermore, it offers comprehensive and predictable error handling. The old HTTP client can still be used.
|
||||
If you weren't extending the internals of the client, this won't be a breaking change for you.
|
||||
|
||||
[discrete]
|
||||
===== Drop support for old camelCased keys
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Medium*
|
||||
|
||||
Currently, every path or query parameter could be expressed in both `snake_case` and `camelCase`. Internally the client will convert everything to `snake_case`.
|
||||
This was done in an effort to reduce the friction of migrating from the legacy to the new client, but now it no longer makes sense.
|
||||
If you are already using `snake_case` keys, this won't be a breaking change for you.
|
||||
|
||||
[discrete]
|
||||
===== Rename `ssl` option to `tls`
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small*
|
||||
|
||||
People usually refers to this as `tls`, furthermore, internally we use the tls API and Node.js refers to it as tls everywhere.
|
||||
[source,js]
|
||||
----
|
||||
// before
|
||||
const client = new Client({
|
||||
node: 'https://localhost:9200',
|
||||
ssl: {
|
||||
rejectUnauthorized: false
|
||||
}
|
||||
})
|
||||
|
||||
// after
|
||||
const client = new Client({
|
||||
node: 'https://localhost:9200',
|
||||
tls: {
|
||||
rejectUnauthorized: false
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
[discrete]
|
||||
===== Remove prototype poisoning protection
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small*
|
||||
|
||||
Prototype poisoning protection is very useful, but it can cause performances issues with big payloads.
|
||||
In v8 it will be removed, and the documentation will show how to add it back with a custom serializer.
|
||||
|
||||
[discrete]
|
||||
===== Remove client extensions API
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Large*
|
||||
|
||||
Nowadays the client support the entire Elasticsearch API, and the `transport.request` method can be used if necessary. The client extensions API have no reason to exist.
|
||||
[source,js]
|
||||
----
|
||||
client.extend('utility.index', ({ makeRequest }) => {
|
||||
return function _index (params, options) {
|
||||
// your code
|
||||
}
|
||||
})
|
||||
|
||||
client.utility.index(...)
|
||||
----
|
||||
|
||||
If you weren't using client extensions, this won't be a breaking change for you.
|
||||
|
||||
[discrete]
|
||||
===== Move to TypeScript
|
||||
|
||||
*Breaking: No* | *Migration effort: None*
|
||||
|
||||
The new separated transport is already written in TypeScript, and it makes sense that the client v8 will be fully written in TypeScript as well.
|
||||
|
||||
[discrete]
|
||||
===== Move from emitter-like interface to a diagnostic method
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small*
|
||||
|
||||
Currently, the client offers a subset of methods of the `EventEmitter` class, v8 will ship with a `diagnostic` property which will be a proper event emitter.
|
||||
[source,js]
|
||||
----
|
||||
// from
|
||||
client.on('request', console.log)
|
||||
|
||||
// to
|
||||
client.diagnostic.on('request', console.log)
|
||||
----
|
||||
|
||||
[discrete]
|
||||
===== Remove username & password properties from Cloud configuration
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small*
|
||||
|
||||
The Cloud configuration does not support ApiKey and Bearer auth, while the `auth` options does.
|
||||
There is no need to keep the legacy basic auth support in the cloud configuration.
|
||||
[source,js]
|
||||
----
|
||||
// before
|
||||
const client = new Client({
|
||||
cloud: {
|
||||
id: '<cloud-id>',
|
||||
username: 'elastic',
|
||||
password: 'changeme'
|
||||
}
|
||||
})
|
||||
|
||||
// after
|
||||
const client = new Client({
|
||||
cloud: {
|
||||
id: '<cloud-id>'
|
||||
},
|
||||
auth: {
|
||||
username: 'elastic',
|
||||
password: 'changeme'
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
If you are already passing the basic auth options in the `auth` configuration, this won't be a breaking change for you.
|
||||
|
||||
[discrete]
|
||||
===== Calling `client.close` will reject new requests
|
||||
|
||||
Once you call `client.close` every new request after that will be rejected with a `NoLivingConnectionsError`. In-flight requests will be executed normally unless an in-flight request requires a retry, in which case it will be rejected.
|
||||
|
||||
[discrete]
|
||||
===== Parameters rename
|
||||
|
||||
- `ilm.delete_lifecycle`: `policy` parameter has been renamed to `name`
|
||||
- `ilm.get_lifecycle`: `policy` parameter has been renamed to `name`
|
||||
- `ilm.put_lifecycle`: `policy` parameter has been renamed to `name`
|
||||
- `snapshot.cleanup_repository`: `repository` parameter has been renamed to `name`
|
||||
- `snapshot.create_repository`: `repository` parameter has been renamed to `name`
|
||||
- `snapshot.delete_repository`: `repository` parameter has been renamed to `name`
|
||||
- `snapshot.get_repository`: `repository` parameter has been renamed to `name`
|
||||
- `snapshot.verify_repository`: `repository` parameter has been renamed to `name`
|
||||
|
||||
[discrete]
|
||||
===== Removal of snake_cased methods
|
||||
|
||||
The v7 client provided snake_cased methods, such as `client.delete_by_query`. This is no longer supported, now only camelCased method are present.
|
||||
So `client.delete_by_query` can be accessed with `client.deleteByQuery`
|
||||
|
||||
@ -28,6 +28,6 @@ const child = client.child({
|
||||
requestTimeout: 1000
|
||||
})
|
||||
|
||||
client.info(console.log)
|
||||
child.info(console.log)
|
||||
client.info().then(console.log, console.log)
|
||||
child.info().then(console.log, console.log)
|
||||
----
|
||||
@ -8,5 +8,4 @@ section, you can see the possible options that you can use to configure it.
|
||||
* <<basic-config>>
|
||||
* <<advanced-config>>
|
||||
* <<child>>
|
||||
* <<extend>>
|
||||
* <<client-testing>>
|
||||
|
||||
@ -6,14 +6,14 @@ This page contains the information you need to connect and use the Client with
|
||||
|
||||
**On this page**
|
||||
|
||||
* <<auth-reference, Authentication options>>
|
||||
* <<authentication, Authentication options>>
|
||||
* <<client-usage, Using the client>>
|
||||
* <<client-faas-env, Using the Client in a Function-as-a-Service Environment>>
|
||||
* <<client-connect-proxy, Connecting through a proxy>>
|
||||
* <<client-error-handling, Handling errors>>
|
||||
* <<product-check, Automatic product check>>
|
||||
|
||||
[[auth-reference]]
|
||||
[[authentication]]
|
||||
[discrete]
|
||||
=== Authentication
|
||||
|
||||
@ -32,7 +32,7 @@ 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
|
||||
throughput improvements. Moreover, the client will also set the tls option
|
||||
`secureProtocol` to `TLSv1_2_method` unless specified otherwise. You can still
|
||||
override this option by configuring them.
|
||||
|
||||
@ -151,13 +151,13 @@ const client = new Client({
|
||||
|
||||
|
||||
[discrete]
|
||||
[[auth-ssl]]
|
||||
==== SSL configuration
|
||||
[[auth-tls]]
|
||||
==== TLS 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
|
||||
certificate verification, you must specify an `tls` object in the top level
|
||||
config and set `rejectUnauthorized: false`. The default `tls` values are the
|
||||
same that Node.js's https://nodejs.org/api/tls.html#tls_tls_connect_options_callback[`tls.connect()`]
|
||||
uses.
|
||||
|
||||
@ -170,7 +170,7 @@ const client = new Client({
|
||||
username: 'elastic',
|
||||
password: 'changeme'
|
||||
},
|
||||
ssl: {
|
||||
tls: {
|
||||
ca: fs.readFileSync('./cacert.pem'),
|
||||
rejectUnauthorized: false
|
||||
}
|
||||
@ -193,7 +193,7 @@ const client = new Client({
|
||||
auth: { ... },
|
||||
// the fingerprint (SHA256) of the CA certificate that is used to sign the certificate that the Elasticsearch node presents for TLS.
|
||||
caFingerprint: '20:0D:CA:FA:76:...',
|
||||
ssl: {
|
||||
tls: {
|
||||
// might be required if it's a self-signed certificate
|
||||
rejectUnauthorized: false
|
||||
}
|
||||
@ -214,31 +214,32 @@ and every method exposes the same signature.
|
||||
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' }
|
||||
}
|
||||
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:
|
||||
The returned value of every API call is the response body from {es}.
|
||||
If you need to access additonal metadata, such as the status code or headers,
|
||||
you must specify `meta: true` in the request options:
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({ node: 'http://localhost:9200' })
|
||||
|
||||
const result = await client.search({
|
||||
index: 'my-index',
|
||||
query: {
|
||||
match: { hello: 'world' }
|
||||
}
|
||||
}, { meta: true })
|
||||
----
|
||||
|
||||
In this case, the result will be:
|
||||
[source,ts]
|
||||
----
|
||||
{
|
||||
@ -252,44 +253,10 @@ The returned value of every API call is designed as follows:
|
||||
|
||||
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.
|
||||
If needed, you can abort a running request by using the `AbortController` standard.
|
||||
|
||||
CAUTION: If you abort a request, the request will fail with a
|
||||
`RequestAbortedError`.
|
||||
@ -297,51 +264,21 @@ CAUTION: If you abort a request, the request will fail with a
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const request = client.search({
|
||||
const AbortController = require('node-abort-controller')
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({ node: 'http://localhost:9200' })
|
||||
|
||||
const abortController = new AbortController()
|
||||
setImmediate(() => abortController.abort())
|
||||
|
||||
const result = await client.search({
|
||||
index: 'my-index',
|
||||
body: {
|
||||
query: {
|
||||
match: { hello: 'world' }
|
||||
}
|
||||
query: {
|
||||
match: { hello: 'world' }
|
||||
}
|
||||
}, {
|
||||
ignore: [404],
|
||||
maxRetries: 3
|
||||
}, (err, result) => {
|
||||
if (err) {
|
||||
console.log(err) // RequestAbortedError
|
||||
} else {
|
||||
console.log(result)
|
||||
}
|
||||
})
|
||||
|
||||
request.abort()
|
||||
}, { signal: abortController.signal })
|
||||
----
|
||||
|
||||
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
|
||||
|
||||
@ -349,7 +286,6 @@ 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: {
|
||||
@ -361,21 +297,6 @@ const result = await client.search({
|
||||
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)
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
@ -427,6 +348,10 @@ _Default:_ `null`
|
||||
|`number` - When configured, it verifies that the compressed response size is lower than the configured number, if it's higher it will abort the request. It cannot be higher than buffer.constants.MAX_LENTGH +
|
||||
_Default:_ `null`
|
||||
|
||||
|`signal`
|
||||
|`AbortSignal` - The AbortSignal instance to allow request abortion. +
|
||||
_Default:_ `null`
|
||||
|
||||
|===
|
||||
|
||||
[discrete]
|
||||
|
||||
@ -12,9 +12,9 @@ const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({ node: 'http://localhost:9200' })
|
||||
|
||||
async function run () {
|
||||
const { body: bulkResponse } = await client.bulk({
|
||||
const bulkResponse = await client.bulk({
|
||||
refresh: true,
|
||||
body: [
|
||||
operations: [
|
||||
// operation to perform
|
||||
{ index: { _index: 'game-of-thrones' } },
|
||||
// the document to index
|
||||
@ -43,13 +43,11 @@ async function run () {
|
||||
}
|
||||
|
||||
// Let's search!
|
||||
const { body } = await client.search({
|
||||
const result = await client.search({
|
||||
index: 'game-of-thrones',
|
||||
body: {
|
||||
query: {
|
||||
match: {
|
||||
quote: 'winter'
|
||||
}
|
||||
query: {
|
||||
match: {
|
||||
quote: 'winter'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
@ -59,17 +57,17 @@ async function run () {
|
||||
// stream async iteration, available in Node.js ≥ 10
|
||||
let payload = ''
|
||||
body.setEncoding('utf8')
|
||||
for await (const chunk of body) {
|
||||
for await (const chunk of result) {
|
||||
payload += chunk
|
||||
}
|
||||
console.log(JSON.parse(payload))
|
||||
|
||||
// classic stream callback style
|
||||
let payload = ''
|
||||
body.setEncoding('utf8')
|
||||
body.on('data', chunk => { payload += chunk })
|
||||
body.on('error', console.log)
|
||||
body.on('end', () => {
|
||||
result.setEncoding('utf8')
|
||||
result.on('data', chunk => { payload += chunk })
|
||||
result.on('error', console.log)
|
||||
result.on('end', () => {
|
||||
console.log(JSON.parse(payload))
|
||||
})
|
||||
}
|
||||
@ -91,9 +89,10 @@ const fastify = require('fastify')()
|
||||
fastify.post('/search/:index', async (req, reply) => {
|
||||
const { body, statusCode, headers } = await client.search({
|
||||
index: req.params.index,
|
||||
body: req.body
|
||||
...req.body
|
||||
}, {
|
||||
asStream: true
|
||||
asStream: true,
|
||||
meta: true
|
||||
})
|
||||
|
||||
reply.code(statusCode).headers(headers)
|
||||
|
||||
@ -19,7 +19,7 @@ const client = new Client({
|
||||
async function run () {
|
||||
await client.indices.create({
|
||||
index: 'tweets',
|
||||
body: {
|
||||
operations: {
|
||||
mappings: {
|
||||
properties: {
|
||||
id: { type: 'integer' },
|
||||
@ -58,9 +58,9 @@ async function run () {
|
||||
date: new Date()
|
||||
}]
|
||||
|
||||
const body = dataset.flatMap(doc => [{ index: { _index: 'tweets' } }, doc])
|
||||
const operations = dataset.flatMap(doc => [{ index: { _index: 'tweets' } }, doc])
|
||||
|
||||
const { body: bulkResponse } = await client.bulk({ refresh: true, body })
|
||||
const bulkResponse = await client.bulk({ refresh: true, operations })
|
||||
|
||||
if (bulkResponse.errors) {
|
||||
const erroredDocuments = []
|
||||
@ -84,7 +84,7 @@ async function run () {
|
||||
console.log(erroredDocuments)
|
||||
}
|
||||
|
||||
const { body: count } = await client.count({ index: 'tweets' })
|
||||
const count = await client.count({ index: 'tweets' })
|
||||
console.log(count)
|
||||
}
|
||||
|
||||
|
||||
@ -16,18 +16,18 @@ async function run () {
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
id: '1',
|
||||
body: {
|
||||
document: {
|
||||
character: 'Ned Stark',
|
||||
quote: 'Winter is coming.'
|
||||
}
|
||||
})
|
||||
|
||||
const { body } = await client.exists({
|
||||
const exists = await client.exists({
|
||||
index: 'game-of-thrones',
|
||||
id: 1
|
||||
})
|
||||
|
||||
console.log(body) // true
|
||||
console.log(exists) // true
|
||||
}
|
||||
|
||||
run().catch(console.log)
|
||||
|
||||
@ -16,18 +16,18 @@ async function run () {
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
id: '1',
|
||||
body: {
|
||||
document: {
|
||||
character: 'Ned Stark',
|
||||
quote: 'Winter is coming.'
|
||||
}
|
||||
})
|
||||
|
||||
const { body } = await client.get({
|
||||
const document = await client.get({
|
||||
index: 'game-of-thrones',
|
||||
id: '1'
|
||||
})
|
||||
|
||||
console.log(body)
|
||||
console.log(document)
|
||||
}
|
||||
|
||||
run().catch(console.log)
|
||||
|
||||
@ -11,9 +11,9 @@ const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({ node: 'http://localhost:9200' })
|
||||
|
||||
async function run () {
|
||||
const { body: bulkResponse } = await client.bulk({
|
||||
const bulkResponse = await client.bulk({
|
||||
refresh: true,
|
||||
body: [
|
||||
operations: [
|
||||
// operation to perform
|
||||
{ index: { _index: 'game-of-thrones' } },
|
||||
// the document to index
|
||||
@ -42,7 +42,7 @@ async function run () {
|
||||
}
|
||||
|
||||
// Let's search!
|
||||
const { body } = await client.search({
|
||||
const result = await client.search({
|
||||
index: 'game-of-thrones',
|
||||
body: {
|
||||
query: {
|
||||
@ -55,7 +55,7 @@ async function run () {
|
||||
ignore: [404]
|
||||
})
|
||||
|
||||
console.log(body) // ResponseError
|
||||
console.log(result) // ResponseError
|
||||
}
|
||||
|
||||
run().catch(console.log)
|
||||
|
||||
@ -17,7 +17,6 @@ Following you can find some examples on how to use the client.
|
||||
* Executing a <<search_examples,search>> request;
|
||||
* I need <<suggest_examples,suggestions>>;
|
||||
* How to use the <<transport_request_examples,transport.request>> method;
|
||||
* How to use <<typescript_examples,TypeScript>>;
|
||||
|
||||
include::asStream.asciidoc[]
|
||||
include::bulk.asciidoc[]
|
||||
@ -29,7 +28,6 @@ include::scroll.asciidoc[]
|
||||
include::search.asciidoc[]
|
||||
include::suggest.asciidoc[]
|
||||
include::transport.request.asciidoc[]
|
||||
include::typescript.asciidoc[]
|
||||
include::sql.query.asciidoc[]
|
||||
include::update.asciidoc[]
|
||||
include::update_by_query.asciidoc[]
|
||||
|
||||
@ -12,9 +12,9 @@ const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({ node: 'http://localhost:9200' })
|
||||
|
||||
async function run () {
|
||||
const { body: bulkResponse } = await client.bulk({
|
||||
const bulkResponse = await client.bulk({
|
||||
refresh: true,
|
||||
body: [
|
||||
operations: [
|
||||
{ index: { _index: 'game-of-thrones' } },
|
||||
{
|
||||
character: 'Ned Stark',
|
||||
@ -40,8 +40,8 @@ async function run () {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const { body } = await client.msearch({
|
||||
body: [
|
||||
const result = await client.msearch({
|
||||
searches: [
|
||||
{ index: 'game-of-thrones' },
|
||||
{ query: { match: { character: 'Daenerys' } } },
|
||||
|
||||
@ -50,7 +50,7 @@ async function run () {
|
||||
]
|
||||
})
|
||||
|
||||
console.log(body.responses)
|
||||
console.log(result.responses)
|
||||
}
|
||||
|
||||
run().catch(console.log)
|
||||
|
||||
@ -70,17 +70,15 @@ module.exports = async (req, res) => {
|
||||
// expose you to the risk that a malicious user
|
||||
// could overload your cluster by crafting
|
||||
// expensive queries.
|
||||
body: {
|
||||
_source: ['id', 'url', 'name'], // the fields you want to show in the autocompletion
|
||||
size: 0,
|
||||
// https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html
|
||||
suggest: {
|
||||
suggestions: {
|
||||
prefix: req.query.q,
|
||||
completion: {
|
||||
field: 'suggest',
|
||||
size: 5
|
||||
}
|
||||
_source: ['id', 'url', 'name'], // the fields you want to show in the autocompletion
|
||||
size: 0,
|
||||
// https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html
|
||||
suggest: {
|
||||
suggestions: {
|
||||
prefix: req.query.q,
|
||||
completion: {
|
||||
field: 'suggest',
|
||||
size: 5
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -93,7 +91,7 @@ module.exports = async (req, res) => {
|
||||
// It might be useful to configure http control caching headers
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
|
||||
// res.setHeader('stale-while-revalidate', '30')
|
||||
res.json(response.body)
|
||||
res.json(response)
|
||||
} catch (err) {
|
||||
res.status(err.statusCode || 500)
|
||||
res.json({
|
||||
|
||||
@ -62,7 +62,7 @@ module.exports = async (req, res) => {
|
||||
}
|
||||
})
|
||||
|
||||
res.json(response.body)
|
||||
res.json(response)
|
||||
} catch (err) {
|
||||
res.status(err.statusCode || 500)
|
||||
res.json({
|
||||
|
||||
@ -56,11 +56,12 @@ module.exports = async (req, res) => {
|
||||
const response = await client.index({
|
||||
index: INDEX,
|
||||
id: req.query.id,
|
||||
body: req.body
|
||||
document: req.body
|
||||
}, {
|
||||
headers: {
|
||||
Authorization: `ApiKey ${token}`
|
||||
}
|
||||
},
|
||||
meta: true
|
||||
})
|
||||
|
||||
res.status(response.statusCode)
|
||||
|
||||
@ -60,10 +60,8 @@ module.exports = async (req, res) => {
|
||||
// expose you to the risk that a malicious user
|
||||
// could overload your cluster by crafting
|
||||
// expensive queries.
|
||||
body: {
|
||||
query: {
|
||||
match: { field: req.body.text }
|
||||
}
|
||||
query: {
|
||||
match: { field: req.body.text }
|
||||
}
|
||||
}, {
|
||||
headers: {
|
||||
@ -74,7 +72,7 @@ module.exports = async (req, res) => {
|
||||
// It might be useful to configure http control caching headers
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
|
||||
// res.setHeader('stale-while-revalidate', '30')
|
||||
res.json(response.body)
|
||||
res.json(response)
|
||||
} catch (err) {
|
||||
res.status(err.statusCode || 500)
|
||||
res.json({
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
"author": "Tomas Della Vedova",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@elastic/elasticsearch": "^7.10.0"
|
||||
"@elastic/elasticsearch": "^8.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"standard": "^16.0.3"
|
||||
|
||||
@ -43,21 +43,19 @@ async function generateApiKeys (opts) {
|
||||
}
|
||||
})
|
||||
|
||||
const { body } = await client.security.createApiKey({
|
||||
body: {
|
||||
name: 'elasticsearch-proxy',
|
||||
role_descriptors: {
|
||||
'elasticsearch-proxy-users': {
|
||||
index: [{
|
||||
names: indexNames,
|
||||
privileges
|
||||
}]
|
||||
}
|
||||
const result = await client.security.createApiKey({
|
||||
name: 'elasticsearch-proxy',
|
||||
role_descriptors: {
|
||||
'elasticsearch-proxy-users': {
|
||||
index: [{
|
||||
names: indexNames,
|
||||
privileges
|
||||
}]
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return Buffer.from(`${body.id}:${body.api_key}`).toString('base64')
|
||||
return Buffer.from(`${result.id}:${result.api_key}`).toString('base64')
|
||||
}
|
||||
|
||||
generateApiKeys()
|
||||
|
||||
@ -20,7 +20,7 @@ const client = new Client({ node: 'http://localhost:9200' })
|
||||
async function run () {
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
body: {
|
||||
document: {
|
||||
character: 'Ned Stark',
|
||||
quote: 'Winter is coming.',
|
||||
house: 'stark'
|
||||
@ -29,7 +29,7 @@ async function run () {
|
||||
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
body: {
|
||||
document: {
|
||||
character: 'Arya Stark',
|
||||
quote: 'A girl is Arya Stark of Winterfell. And I\'m going home.',
|
||||
house: 'stark'
|
||||
@ -39,7 +39,7 @@ async function run () {
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
refresh: true,
|
||||
body: {
|
||||
document: {
|
||||
character: 'Tyrion Lannister',
|
||||
quote: 'A Lannister always pays his debts.',
|
||||
house: 'lannister'
|
||||
@ -47,33 +47,29 @@ async function run () {
|
||||
})
|
||||
|
||||
await client.reindex({
|
||||
waitForCompletion: true,
|
||||
wait_for_completion: true,
|
||||
refresh: true,
|
||||
body: {
|
||||
source: {
|
||||
index: 'game-of-thrones',
|
||||
query: {
|
||||
match: { character: 'stark' }
|
||||
}
|
||||
},
|
||||
dest: {
|
||||
index: 'stark-index'
|
||||
},
|
||||
script: {
|
||||
lang: 'painless',
|
||||
source: 'ctx._source.remove("house")'
|
||||
source: {
|
||||
index: 'game-of-thrones',
|
||||
query: {
|
||||
match: { character: 'stark' }
|
||||
}
|
||||
},
|
||||
dest: {
|
||||
index: 'stark-index'
|
||||
},
|
||||
script: {
|
||||
lang: 'painless',
|
||||
source: 'ctx._source.remove("house")'
|
||||
}
|
||||
})
|
||||
|
||||
const { body } = await client.search({
|
||||
const result = await client.search({
|
||||
index: 'stark-index',
|
||||
body: {
|
||||
query: { match_all: {} }
|
||||
}
|
||||
query: { match_all: {} }
|
||||
})
|
||||
|
||||
console.log(body.hits.hits)
|
||||
console.log(result.hits.hits)
|
||||
}
|
||||
|
||||
run().catch(console.log)
|
||||
|
||||
@ -33,12 +33,12 @@ async function run () {
|
||||
const responseQueue = []
|
||||
|
||||
// Let's index some data!
|
||||
const { body: bulkResponse } = await client.bulk({
|
||||
const bulkResponse = await client.bulk({
|
||||
// here we are forcing an index refresh,
|
||||
// otherwise we will not get any result
|
||||
// in the consequent search
|
||||
refresh: true,
|
||||
body: [
|
||||
operations: [
|
||||
// operation to perform
|
||||
{ index: { _index: 'game-of-thrones' } },
|
||||
// the document to index
|
||||
@ -76,17 +76,15 @@ async function run () {
|
||||
size: 1,
|
||||
// filter the source to only include the quote field
|
||||
_source: ['quote'],
|
||||
body: {
|
||||
query: {
|
||||
match_all: {}
|
||||
}
|
||||
query: {
|
||||
match_all: {}
|
||||
}
|
||||
})
|
||||
|
||||
responseQueue.push(response)
|
||||
|
||||
while (responseQueue.length) {
|
||||
const { body } = responseQueue.shift()
|
||||
const body = responseQueue.shift()
|
||||
|
||||
// collect the titles from this response
|
||||
body.hits.hits.forEach(function (hit) {
|
||||
@ -127,7 +125,7 @@ async function * scrollSearch (params) {
|
||||
let response = await client.search(params)
|
||||
|
||||
while (true) {
|
||||
const sourceHits = response.body.hits.hits
|
||||
const sourceHits = response.hits.hits
|
||||
|
||||
if (sourceHits.length === 0) {
|
||||
break
|
||||
@ -137,12 +135,12 @@ async function * scrollSearch (params) {
|
||||
yield hit
|
||||
}
|
||||
|
||||
if (!response.body._scroll_id) {
|
||||
if (!response._scroll_id) {
|
||||
break
|
||||
}
|
||||
|
||||
response = await client.scroll({
|
||||
scrollId: response.body._scroll_id,
|
||||
scrollId: response._scroll_id,
|
||||
scroll: params.scroll
|
||||
})
|
||||
}
|
||||
@ -151,7 +149,7 @@ async function * scrollSearch (params) {
|
||||
async function run () {
|
||||
await client.bulk({
|
||||
refresh: true,
|
||||
body: [
|
||||
operations: [
|
||||
{ index: { _index: 'game-of-thrones' } },
|
||||
{
|
||||
character: 'Ned Stark',
|
||||
@ -177,10 +175,8 @@ async function run () {
|
||||
scroll: '30s',
|
||||
size: 1,
|
||||
_source: ['quote'],
|
||||
body: {
|
||||
query: {
|
||||
match_all: {}
|
||||
}
|
||||
query: {
|
||||
match_all: {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ async function run () {
|
||||
// Let's start by indexing some data
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
body: {
|
||||
document: {
|
||||
character: 'Ned Stark',
|
||||
quote: 'Winter is coming.'
|
||||
}
|
||||
@ -26,7 +26,7 @@ async function run () {
|
||||
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
body: {
|
||||
document: {
|
||||
character: 'Daenerys Targaryen',
|
||||
quote: 'I am the blood of the dragon.'
|
||||
}
|
||||
@ -38,25 +38,23 @@ async function run () {
|
||||
// otherwise we will not get any result
|
||||
// in the consequent search
|
||||
refresh: true,
|
||||
body: {
|
||||
document: {
|
||||
character: 'Tyrion Lannister',
|
||||
quote: 'A mind needs books like a sword needs a whetstone.'
|
||||
}
|
||||
})
|
||||
|
||||
// Let's search!
|
||||
const { body } = await client.search({
|
||||
const result = await client.search({
|
||||
index: 'game-of-thrones',
|
||||
body: {
|
||||
query: {
|
||||
match: {
|
||||
quote: 'winter'
|
||||
}
|
||||
query: {
|
||||
match: {
|
||||
quote: 'winter'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
console.log(body.hits.hits)
|
||||
console.log(result.hits.hits)
|
||||
}
|
||||
|
||||
run().catch(console.log)
|
||||
|
||||
@ -22,7 +22,7 @@ const client = new Client({ node: 'http://localhost:9200' })
|
||||
async function run () {
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
body: {
|
||||
document: {
|
||||
character: 'Ned Stark',
|
||||
quote: 'Winter is coming.',
|
||||
house: 'stark'
|
||||
@ -31,7 +31,7 @@ async function run () {
|
||||
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
body: {
|
||||
document: {
|
||||
character: 'Arya Stark',
|
||||
quote: 'A girl is Arya Stark of Winterfell. And I\'m going home.',
|
||||
house: 'stark'
|
||||
@ -41,25 +41,23 @@ async function run () {
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
refresh: true,
|
||||
body: {
|
||||
document: {
|
||||
character: 'Tyrion Lannister',
|
||||
quote: 'A Lannister always pays his debts.',
|
||||
house: 'lannister'
|
||||
}
|
||||
})
|
||||
|
||||
const { body } = await client.sql.query({
|
||||
body: {
|
||||
query: "SELECT * FROM \"game-of-thrones\" WHERE house='stark'"
|
||||
}
|
||||
const result = await client.sql.query({
|
||||
query: "SELECT * FROM \"game-of-thrones\" WHERE house='stark'"
|
||||
})
|
||||
|
||||
console.log(body)
|
||||
console.log(result)
|
||||
|
||||
const data = body.rows.map(row => {
|
||||
const data = result.rows.map(row => {
|
||||
const obj = {}
|
||||
for (let i = 0; i < row.length; i++) {
|
||||
obj[body.columns[i].name] = row[i]
|
||||
obj[result.columns[i].name] = row[i]
|
||||
}
|
||||
return obj
|
||||
})
|
||||
|
||||
@ -15,9 +15,9 @@ const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({ node: 'http://localhost:9200' })
|
||||
|
||||
async function run () {
|
||||
const { body: bulkResponse } = await client.bulk({
|
||||
const bulkResponse = await client.bulk({
|
||||
refresh: true,
|
||||
body: [
|
||||
operations: [
|
||||
{ index: { _index: 'game-of-thrones' } },
|
||||
{
|
||||
character: 'Ned Stark',
|
||||
@ -43,22 +43,20 @@ async function run () {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const { body } = await client.search({
|
||||
const result = await client.search({
|
||||
index: 'game-of-thrones',
|
||||
body: {
|
||||
query: {
|
||||
match: { quote: 'witner' }
|
||||
},
|
||||
suggest: {
|
||||
gotsuggest: {
|
||||
text: 'witner',
|
||||
term: { field: 'quote' }
|
||||
}
|
||||
query: {
|
||||
match: { quote: 'winter' }
|
||||
},
|
||||
suggest: {
|
||||
gotsuggest: {
|
||||
text: 'winter',
|
||||
term: { field: 'quote' }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
console.log(body)
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
run().catch(console.log)
|
||||
|
||||
@ -23,9 +23,9 @@ const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({ node: 'http://localhost:9200' })
|
||||
|
||||
async function run () {
|
||||
const { body: bulkResponse } = await client.bulk({
|
||||
const bulkResponse = await client.bulk({
|
||||
refresh: true,
|
||||
body: [
|
||||
operations: [
|
||||
{ index: { _index: 'game-of-thrones' } },
|
||||
{
|
||||
character: 'Ned Stark',
|
||||
@ -51,7 +51,7 @@ async function run () {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const { body } = await client.transport.request({
|
||||
const response = await client.transport.request({
|
||||
method: 'POST',
|
||||
path: '/game-of-thrones/_search',
|
||||
body: {
|
||||
@ -64,7 +64,7 @@ async function run () {
|
||||
querystring: {}
|
||||
})
|
||||
|
||||
console.log(body)
|
||||
console.log(response)
|
||||
}
|
||||
|
||||
run().catch(console.log)
|
||||
|
||||
@ -1,72 +0,0 @@
|
||||
[[typescript_examples]]
|
||||
=== Typescript
|
||||
|
||||
The client offers a first-class support for TypeScript, since it ships the type
|
||||
definitions for every exposed API.
|
||||
|
||||
NOTE: If you are using TypeScript you will be required to use _snake_case_ style
|
||||
to define the API parameters instead of _camelCase_.
|
||||
|
||||
[source,ts]
|
||||
----
|
||||
'use strict'
|
||||
|
||||
import { Client, ApiResponse, RequestParams } from '@elastic/elasticsearch'
|
||||
const client = new Client({ node: 'http://localhost:9200' })
|
||||
|
||||
async function run (): void {
|
||||
// Let's start by indexing some data
|
||||
const doc1: RequestParams.Index = {
|
||||
index: 'game-of-thrones',
|
||||
body: {
|
||||
character: 'Ned Stark',
|
||||
quote: 'Winter is coming.'
|
||||
}
|
||||
}
|
||||
await client.index(doc1)
|
||||
|
||||
const doc2: RequestParams.Index = {
|
||||
index: 'game-of-thrones',
|
||||
body: {
|
||||
character: 'Daenerys Targaryen',
|
||||
quote: 'I am the blood of the dragon.'
|
||||
}
|
||||
}
|
||||
await client.index(doc2)
|
||||
|
||||
const doc3: RequestParams.Index = {
|
||||
index: 'game-of-thrones',
|
||||
// here we are forcing an index refresh,
|
||||
// otherwise we will not get any result
|
||||
// in the consequent search
|
||||
refresh: true,
|
||||
body: {
|
||||
character: 'Tyrion Lannister',
|
||||
quote: 'A mind needs books like a sword needs a whetstone.'
|
||||
}
|
||||
}
|
||||
await client.index(doc3)
|
||||
|
||||
// Let's search!
|
||||
const params: RequestParams.Search = {
|
||||
index: 'game-of-thrones',
|
||||
body: {
|
||||
query: {
|
||||
match: {
|
||||
quote: 'winter'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
client
|
||||
.search(params)
|
||||
.then((result: ApiResponse) => {
|
||||
console.log(result.body.hits.hits)
|
||||
})
|
||||
.catch((err: Error) => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
|
||||
run()
|
||||
----
|
||||
@ -16,7 +16,7 @@ async function run () {
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
id: '1',
|
||||
body: {
|
||||
document: {
|
||||
character: 'Ned Stark',
|
||||
quote: 'Winter is coming.',
|
||||
times: 0
|
||||
@ -26,23 +26,21 @@ async function run () {
|
||||
await client.update({
|
||||
index: 'game-of-thrones',
|
||||
id: '1',
|
||||
body: {
|
||||
script: {
|
||||
lang: 'painless',
|
||||
source: 'ctx._source.times++'
|
||||
// you can also use parameters
|
||||
// source: 'ctx._source.times += params.count',
|
||||
// params: { count: 1 }
|
||||
}
|
||||
script: {
|
||||
lang: 'painless',
|
||||
source: 'ctx._source.times++'
|
||||
// you can also use parameters
|
||||
// source: 'ctx._source.times += params.count',
|
||||
// params: { count: 1 }
|
||||
}
|
||||
})
|
||||
|
||||
const { body } = await client.get({
|
||||
const document = await client.get({
|
||||
index: 'game-of-thrones',
|
||||
id: '1'
|
||||
})
|
||||
|
||||
console.log(body)
|
||||
console.log(document)
|
||||
}
|
||||
|
||||
run().catch(console.log)
|
||||
@ -62,7 +60,7 @@ async function run () {
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
id: '1',
|
||||
body: {
|
||||
document: {
|
||||
character: 'Ned Stark',
|
||||
quote: 'Winter is coming.',
|
||||
isAlive: true
|
||||
@ -72,19 +70,17 @@ async function run () {
|
||||
await client.update({
|
||||
index: 'game-of-thrones',
|
||||
id: '1',
|
||||
body: {
|
||||
doc: {
|
||||
isAlive: false
|
||||
}
|
||||
doc: {
|
||||
isAlive: false
|
||||
}
|
||||
})
|
||||
|
||||
const { body } = await client.get({
|
||||
const document = await client.get({
|
||||
index: 'game-of-thrones',
|
||||
id: '1'
|
||||
})
|
||||
|
||||
console.log(body)
|
||||
console.log(document)
|
||||
}
|
||||
|
||||
run().catch(console.log)
|
||||
|
||||
@ -15,7 +15,7 @@ const client = new Client({ node: 'http://localhost:9200' })
|
||||
async function run () {
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
body: {
|
||||
document: {
|
||||
character: 'Ned Stark',
|
||||
quote: 'Winter is coming.'
|
||||
}
|
||||
@ -24,7 +24,7 @@ async function run () {
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
refresh: true,
|
||||
body: {
|
||||
document: {
|
||||
character: 'Arya Stark',
|
||||
quote: 'A girl is Arya Stark of Winterfell. And I\'m going home.'
|
||||
}
|
||||
@ -33,27 +33,23 @@ async function run () {
|
||||
await client.updateByQuery({
|
||||
index: 'game-of-thrones',
|
||||
refresh: true,
|
||||
body: {
|
||||
script: {
|
||||
lang: 'painless',
|
||||
source: 'ctx._source["house"] = "stark"'
|
||||
},
|
||||
query: {
|
||||
match: {
|
||||
character: 'stark'
|
||||
}
|
||||
script: {
|
||||
lang: 'painless',
|
||||
source: 'ctx._source["house"] = "stark"'
|
||||
},
|
||||
query: {
|
||||
match: {
|
||||
character: 'stark'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const { body } = await client.search({
|
||||
const result = await client.search({
|
||||
index: 'game-of-thrones',
|
||||
body: {
|
||||
query: { match_all: {} }
|
||||
}
|
||||
query: { match_all: {} }
|
||||
})
|
||||
|
||||
console.log(body.hits.hits)
|
||||
console.log(result.hits.hits)
|
||||
}
|
||||
|
||||
run().catch(console.log)
|
||||
|
||||
@ -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(...)
|
||||
----
|
||||
@ -341,23 +341,12 @@ 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
|
||||
@ -474,11 +463,9 @@ the query string.
|
||||
----
|
||||
const documents = await client.helpers.search({
|
||||
index: 'stackoverflow',
|
||||
body: {
|
||||
query: {
|
||||
match: {
|
||||
title: 'javascript'
|
||||
}
|
||||
query: {
|
||||
match: {
|
||||
title: 'javascript'
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -505,11 +492,9 @@ the `429` error and uses the `maxRetries` option of the client.
|
||||
----
|
||||
const scrollSearch = client.helpers.scrollSearch({
|
||||
index: 'stackoverflow',
|
||||
body: {
|
||||
query: {
|
||||
match: {
|
||||
title: 'javascript'
|
||||
}
|
||||
query: {
|
||||
match: {
|
||||
title: 'javascript'
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -564,11 +549,9 @@ automatically adds `filter_path=hits.hits._source` to the query string.
|
||||
----
|
||||
const scrollSearch = client.helpers.scrollDocuments({
|
||||
index: 'stackoverflow',
|
||||
body: {
|
||||
query: {
|
||||
match: {
|
||||
title: 'javascript'
|
||||
}
|
||||
query: {
|
||||
match: {
|
||||
title: 'javascript'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
include::{asciidoc-dir}/../../shared/attributes.asciidoc[]
|
||||
|
||||
include::introduction.asciidoc[]
|
||||
include::changelog.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[]
|
||||
@ -19,3 +19,4 @@ include::typescript.asciidoc[]
|
||||
include::reference.asciidoc[]
|
||||
include::examples/index.asciidoc[]
|
||||
include::helpers.asciidoc[]
|
||||
include::redirects.asciidoc[]
|
||||
|
||||
@ -56,6 +56,10 @@ of `^7.10.0`).
|
||||
|`10.x`
|
||||
|April 2021
|
||||
|`7.12` (mid 2021)
|
||||
|
||||
|`12.x`
|
||||
|April 2022
|
||||
|`8.2` (early 2022)
|
||||
|===
|
||||
|
||||
[discrete]
|
||||
@ -70,8 +74,8 @@ Elasticsearch language clients are only backwards compatible with default distri
|
||||
|{es} Version
|
||||
|Client Version
|
||||
|
||||
|`main`
|
||||
|`main`
|
||||
|`8.x`
|
||||
|`8.x`
|
||||
|
||||
|`7.x`
|
||||
|`7.x`
|
||||
|
||||
@ -4,9 +4,6 @@
|
||||
This is the official Node.js client for {es}. This page gives a quick overview
|
||||
about the features of the client.
|
||||
|
||||
Refer to <<breaking-changes,this page>> for breaking changes coming from the old
|
||||
client.
|
||||
|
||||
|
||||
[discrete]
|
||||
=== Features
|
||||
@ -23,59 +20,6 @@ client.
|
||||
[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'
|
||||
@ -87,8 +31,7 @@ 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: {
|
||||
document: {
|
||||
character: 'Ned Stark',
|
||||
quote: 'Winter is coming.'
|
||||
}
|
||||
@ -96,8 +39,7 @@ async function run () {
|
||||
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
// type: '_doc', // uncomment this line if you are using {es} ≤ 6
|
||||
body: {
|
||||
document: {
|
||||
character: 'Daenerys Targaryen',
|
||||
quote: 'I am the blood of the dragon.'
|
||||
}
|
||||
@ -105,29 +47,25 @@ async function run () {
|
||||
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
// type: '_doc', // uncomment this line if you are using {es} ≤ 6
|
||||
body: {
|
||||
document: {
|
||||
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
|
||||
// here we are forcing an index refresh, 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({
|
||||
const result= await client.search({
|
||||
index: 'game-of-thrones',
|
||||
// type: '_doc', // uncomment this line if you are using {es} ≤ 6
|
||||
body: {
|
||||
query: {
|
||||
match: { quote: 'winter' }
|
||||
}
|
||||
query: {
|
||||
match: { quote: 'winter' }
|
||||
}
|
||||
})
|
||||
|
||||
console.log(body.hits.hits)
|
||||
console.log(result.hits.hits)
|
||||
}
|
||||
|
||||
run().catch(console.log)
|
||||
@ -181,20 +119,17 @@ 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)
|
||||
client6.info().then(console.log, console.log)
|
||||
client7.info().then(console.log, 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:
|
||||
that lives in the {es} main branch), use the following command:
|
||||
|
||||
[source,sh]
|
||||
----
|
||||
npm install esmaster@github:elastic/elasticsearch-js
|
||||
npm install esmain@github:elastic/elasticsearch-js
|
||||
----
|
||||
WARNING: This command installs the master branch of the client which is not
|
||||
considered stable.
|
||||
|
||||
|
||||
include::breaking-changes.asciidoc[]
|
||||
WARNING: This command installs the main branch of the client which is not
|
||||
considered stable.
|
||||
@ -2,7 +2,7 @@
|
||||
=== 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
|
||||
emitter interface to hook into internal events, such as `request` and
|
||||
`response`.
|
||||
|
||||
Correlating those events can be hard, especially if your applications have a
|
||||
@ -36,7 +36,7 @@ const logger = require('my-logger')()
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({ node: 'http://localhost:9200' })
|
||||
|
||||
client.on('response', (err, result) => {
|
||||
client.diagnostic.on('response', (err, result) => {
|
||||
if (err) {
|
||||
logger.error(err)
|
||||
} else {
|
||||
@ -53,7 +53,7 @@ The client emits the following events:
|
||||
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) => {
|
||||
client.diagnostic.on('serialization', (err, result) => {
|
||||
console.log(err, result)
|
||||
})
|
||||
----
|
||||
@ -62,7 +62,7 @@ client.on('serialization', (err, result) => {
|
||||
a|Emitted before sending the actual request to {es} _(emitted multiple times in case of retries)_.
|
||||
[source,js]
|
||||
----
|
||||
client.on('request', (err, result) => {
|
||||
client.diagnostic.on('request', (err, result) => {
|
||||
console.log(err, result)
|
||||
})
|
||||
----
|
||||
@ -71,7 +71,7 @@ client.on('request', (err, result) => {
|
||||
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) => {
|
||||
client.diagnostic.on('deserialization', (err, result) => {
|
||||
console.log(err, result)
|
||||
})
|
||||
----
|
||||
@ -80,7 +80,7 @@ client.on('deserialization', (err, result) => {
|
||||
a|Emitted once {es} response has been received and parsed.
|
||||
[source,js]
|
||||
----
|
||||
client.on('response', (err, result) => {
|
||||
client.diagnostic.on('response', (err, result) => {
|
||||
console.log(err, result)
|
||||
})
|
||||
----
|
||||
@ -89,7 +89,7 @@ client.on('response', (err, result) => {
|
||||
a|Emitted when the client ends a sniffing request.
|
||||
[source,js]
|
||||
----
|
||||
client.on('sniff', (err, result) => {
|
||||
client.diagnostic.on('sniff', (err, result) => {
|
||||
console.log(err, result)
|
||||
})
|
||||
----
|
||||
@ -98,7 +98,7 @@ client.on('sniff', (err, result) => {
|
||||
a|Emitted if the client is able to resurrect a dead node.
|
||||
[source,js]
|
||||
----
|
||||
client.on('resurrect', (err, result) => {
|
||||
client.diagnostic.on('resurrect', (err, result) => {
|
||||
console.log(err, result)
|
||||
})
|
||||
----
|
||||
@ -185,14 +185,14 @@ handle this problem.
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({ node: 'http://localhost:9200' })
|
||||
|
||||
client.on('request', (err, result) => {
|
||||
client.diagnostic.on('request', (err, result) => {
|
||||
const { id } = result.meta.request
|
||||
if (err) {
|
||||
console.log({ error: err, reqId: id })
|
||||
}
|
||||
})
|
||||
|
||||
client.on('response', (err, result) => {
|
||||
client.diagnostic.on('response', (err, result) => {
|
||||
const { id } = result.meta.request
|
||||
if (err) {
|
||||
console.log({ error: err, reqId: id })
|
||||
@ -201,10 +201,8 @@ client.on('response', (err, result) => {
|
||||
|
||||
client.search({
|
||||
index: 'my-index',
|
||||
body: { foo: 'bar' }
|
||||
}, (err, result) => {
|
||||
if (err) console.log(err)
|
||||
})
|
||||
query: { match_all: {} }
|
||||
}).then(console.log, console.log)
|
||||
----
|
||||
|
||||
|
||||
@ -232,12 +230,10 @@ You can also specify a custom id per request:
|
||||
----
|
||||
client.search({
|
||||
index: 'my-index',
|
||||
body: { foo: 'bar' }
|
||||
query: { match_all: {} }
|
||||
}, {
|
||||
id: 'custom-id'
|
||||
}, (err, result) => {
|
||||
if (err) console.log(err)
|
||||
})
|
||||
}).then(console.log, console.log)
|
||||
----
|
||||
|
||||
|
||||
@ -252,7 +248,7 @@ can do that via the `context` option of a request:
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({ node: 'http://localhost:9200' })
|
||||
|
||||
client.on('request', (err, result) => {
|
||||
client.diagnostic.on('request', (err, result) => {
|
||||
const { id } = result.meta.request
|
||||
const { context } = result.meta
|
||||
if (err) {
|
||||
@ -260,7 +256,7 @@ client.on('request', (err, result) => {
|
||||
}
|
||||
})
|
||||
|
||||
client.on('response', (err, result) => {
|
||||
client.diagnostic.on('response', (err, result) => {
|
||||
const { id } = result.meta.request
|
||||
const { winter } = result.meta.context
|
||||
if (err) {
|
||||
@ -270,12 +266,10 @@ client.on('response', (err, result) => {
|
||||
|
||||
client.search({
|
||||
index: 'my-index',
|
||||
body: { foo: 'bar' }
|
||||
query: { match_all: {} }
|
||||
}, {
|
||||
context: { winter: 'is coming' }
|
||||
}, (err, result) => {
|
||||
if (err) console.log(err)
|
||||
})
|
||||
}).then(console.log, console.log)
|
||||
----
|
||||
|
||||
The context object can also be configured as a global option in the client
|
||||
@ -290,7 +284,7 @@ const client = new Client({
|
||||
context: { winter: 'is coming' }
|
||||
})
|
||||
|
||||
client.on('request', (err, result) => {
|
||||
client.diagnostic.on('request', (err, result) => {
|
||||
const { id } = result.meta.request
|
||||
const { context } = result.meta
|
||||
if (err) {
|
||||
@ -298,7 +292,7 @@ client.on('request', (err, result) => {
|
||||
}
|
||||
})
|
||||
|
||||
client.on('response', (err, result) => {
|
||||
client.diagnostic.on('response', (err, result) => {
|
||||
const { id } = result.meta.request
|
||||
const { winter } = result.meta.context
|
||||
if (err) {
|
||||
@ -308,12 +302,10 @@ client.on('response', (err, result) => {
|
||||
|
||||
client.search({
|
||||
index: 'my-index',
|
||||
body: { foo: 'bar' }
|
||||
query: { match_all: {} }
|
||||
}, {
|
||||
context: { winter: 'has come' }
|
||||
}, (err, result) => {
|
||||
if (err) console.log(err)
|
||||
})
|
||||
}).then(console.log, console.log)
|
||||
----
|
||||
|
||||
|
||||
@ -339,7 +331,7 @@ const child = client.child({
|
||||
|
||||
console.log(client.name, child.name)
|
||||
|
||||
client.on('request', (err, result) => {
|
||||
client.diagnostic.on('request', (err, result) => {
|
||||
const { id } = result.meta.request
|
||||
const { name } = result.meta
|
||||
if (err) {
|
||||
@ -347,7 +339,7 @@ client.on('request', (err, result) => {
|
||||
}
|
||||
})
|
||||
|
||||
client.on('response', (err, result) => {
|
||||
client.diagnostic.on('response', (err, result) => {
|
||||
const { id } = result.meta.request
|
||||
const { name } = result.meta
|
||||
if (err) {
|
||||
@ -357,17 +349,13 @@ client.on('response', (err, result) => {
|
||||
|
||||
client.search({
|
||||
index: 'my-index',
|
||||
body: { foo: 'bar' }
|
||||
}, (err, result) => {
|
||||
if (err) console.log(err)
|
||||
})
|
||||
query: { match_all: {} }
|
||||
}).then(console.log, console.log)
|
||||
|
||||
child.search({
|
||||
index: 'my-index',
|
||||
body: { foo: 'bar' }
|
||||
}, (err, result) => {
|
||||
if (err) console.log(err)
|
||||
})
|
||||
query: { match_all: {} }
|
||||
}).then(console.log, console.log)
|
||||
----
|
||||
|
||||
|
||||
@ -397,9 +385,7 @@ client.search({
|
||||
body: { foo: 'bar' }
|
||||
}, {
|
||||
opaqueId: 'my-search'
|
||||
}, (err, result) => {
|
||||
if (err) console.log(err)
|
||||
})
|
||||
}).then(console.log, console.log)
|
||||
----
|
||||
|
||||
Sometimes it may be useful to prefix all the `X-Opaque-Id` headers with a
|
||||
@ -421,8 +407,6 @@ client.search({
|
||||
body: { foo: 'bar' }
|
||||
}, {
|
||||
opaqueId: 'my-search'
|
||||
}, (err, result) => {
|
||||
if (err) console.log(err)
|
||||
})
|
||||
}).then(console.log, console.log)
|
||||
----
|
||||
|
||||
|
||||
17
docs/redirects.asciidoc
Normal file
17
docs/redirects.asciidoc
Normal file
@ -0,0 +1,17 @@
|
||||
["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 <<client-connecting>>.
|
||||
|
||||
[role="exclude",id="breaking-changes"]
|
||||
== Breaking changes
|
||||
|
||||
For information about migrating from the legacy elasticsearch.js client to the
|
||||
new Elasticsearch JavaScript client, refer to the
|
||||
https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/7.17/breaking-changes.html[7.17
|
||||
JavaScript client migration guide].
|
||||
15052
docs/reference.asciidoc
15052
docs/reference.asciidoc
File diff suppressed because it is too large
Load Diff
@ -72,7 +72,7 @@ mock.add({
|
||||
return { status: 'ok' }
|
||||
})
|
||||
|
||||
client.info(console.log)
|
||||
client.info().then(console.log, console.log)
|
||||
----
|
||||
|
||||
As you can see it works closely with the client itself, once you have created a
|
||||
@ -129,8 +129,8 @@ mock.add({
|
||||
return { count: 42 }
|
||||
})
|
||||
|
||||
client.count({ index: 'foo' }, console.log) // => { count: 42 }
|
||||
client.count({ index: 'bar' }, console.log) // => { count: 42 }
|
||||
client.count({ index: 'foo' }).then(console.log, console.log) // => { count: 42 }
|
||||
client.count({ index: 'bar' }).then(console.log, console.log) // => { count: 42 }
|
||||
----
|
||||
|
||||
And wildcards are supported as well.
|
||||
|
||||
@ -4,274 +4,73 @@
|
||||
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<SearchResponse<Source>, SearchBody>({
|
||||
index: 'test',
|
||||
body: {
|
||||
query: {
|
||||
match: { foo: 'bar' }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// new definitions
|
||||
const response = await client.search<Source>({
|
||||
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<Source> = {
|
||||
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.
|
||||
==== Example
|
||||
|
||||
[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<Source>({
|
||||
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 = Record<string, any>> = T | string | Buffer | ReadableStream
|
||||
type RequestNDBody<T = Record<string, any>[]> = 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<ResponseBody, RequestBody, Context>({
|
||||
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<T> {
|
||||
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
|
||||
interface Document {
|
||||
character: string
|
||||
quote: 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<string, any>`.
|
||||
let response = await client.search({
|
||||
index: 'test',
|
||||
body: {
|
||||
query: {
|
||||
match: { foo: 'bar' }
|
||||
}
|
||||
// Let's start by indexing some data
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
document: {
|
||||
character: 'Ned Stark',
|
||||
quote: 'Winter is coming.'
|
||||
}
|
||||
})
|
||||
// body here is `ResponseBody`
|
||||
console.log(response.body)
|
||||
|
||||
// The first generic is the response body
|
||||
response = await client.search<SearchResponse<Source>>({
|
||||
index: 'test',
|
||||
// Here the body must follow the `RequestBody` interface
|
||||
body: {
|
||||
query: {
|
||||
match: { foo: 'bar' }
|
||||
}
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
document: {
|
||||
character: 'Daenerys Targaryen',
|
||||
quote: 'I am the blood of the dragon.'
|
||||
}
|
||||
})
|
||||
// body here is `SearchResponse<Source>`
|
||||
console.log(response.body)
|
||||
|
||||
response = await client.search<SearchResponse<Source>, SearchBody>({
|
||||
index: 'test',
|
||||
// Here the body must follow the `SearchBody` interface
|
||||
body: {
|
||||
query: {
|
||||
match: { foo: 'bar' }
|
||||
}
|
||||
await client.index({
|
||||
index: 'game-of-thrones',
|
||||
document: {
|
||||
character: 'Tyrion Lannister',
|
||||
quote: 'A mind needs books like a sword needs a whetstone.'
|
||||
}
|
||||
})
|
||||
// body here is `SearchResponse<Source>`
|
||||
console.log(response.body)
|
||||
|
||||
// here we are forcing an index refresh, otherwise we will not
|
||||
// get any result in the consequent search
|
||||
await client.indices.refresh({ index: 'game-of-thrones' })
|
||||
|
||||
// Let's search!
|
||||
const result= await client.search<Document>({
|
||||
index: 'game-of-thrones',
|
||||
query: {
|
||||
match: { quote: 'winter' }
|
||||
}
|
||||
})
|
||||
|
||||
console.log(result.hits.hits)
|
||||
}
|
||||
|
||||
run().catch(console.log)
|
||||
----
|
||||
|
||||
[discrete]
|
||||
==== Request & Response types
|
||||
|
||||
You can import the full TypeScript requests & responses defintions as it follows:
|
||||
|
||||
[source,ts]
|
||||
----
|
||||
import { estypes } from '@elastic/elasticsearch'
|
||||
----
|
||||
3
index.d.ts
vendored
3
index.d.ts
vendored
@ -18,7 +18,8 @@
|
||||
*/
|
||||
|
||||
import Client from './lib/client'
|
||||
import SniffingTransport from './lib/sniffingTransport'
|
||||
|
||||
export * from '@elastic/transport'
|
||||
export { Client }
|
||||
export { Client, SniffingTransport }
|
||||
export type { ClientOptions, NodeOptions } from './lib/client'
|
||||
|
||||
2
index.js
2
index.js
@ -35,9 +35,11 @@ const {
|
||||
} = require('@elastic/transport')
|
||||
|
||||
const { default: Client } = require('./lib/client')
|
||||
const { default: SniffingTransport } = require('./lib/sniffingTransport')
|
||||
|
||||
module.exports = {
|
||||
Client,
|
||||
SniffingTransport,
|
||||
Diagnostic,
|
||||
Transport,
|
||||
WeightedConnectionPool,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@elastic/elasticsearch",
|
||||
"version": "8.1.0-beta.1",
|
||||
"versionCanary": "8.1.0-canary.2",
|
||||
"version": "8.1.0",
|
||||
"versionCanary": "8.1.0-canary.3",
|
||||
"description": "The official Elasticsearch client for Node.js",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
@ -80,7 +80,7 @@
|
||||
"xmlbuilder2": "^3.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@elastic/transport": "^8.1.0-beta.1",
|
||||
"@elastic/transport": "^8.0.2",
|
||||
"tslib": "^2.3.0"
|
||||
},
|
||||
"tap": {
|
||||
|
||||
111
src/api/api/_internal.ts
Normal file
111
src/api/api/_internal.ts
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/* eslint-disable import/export */
|
||||
/* eslint-disable @typescript-eslint/no-misused-new */
|
||||
/* eslint-disable @typescript-eslint/no-extraneous-class */
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
|
||||
// This file was automatically generated by elastic/elastic-client-generator-js
|
||||
// DO NOT MODIFY IT BY HAND. Instead, modify the source open api file,
|
||||
// and elastic/elastic-client-generator-js to regenerate this file again.
|
||||
|
||||
import {
|
||||
Transport,
|
||||
TransportRequestOptions,
|
||||
TransportRequestOptionsWithMeta,
|
||||
TransportRequestOptionsWithOutMeta,
|
||||
TransportResult
|
||||
} from '@elastic/transport'
|
||||
import * as T from '../types'
|
||||
import * as TB from '../typesWithBodyKey'
|
||||
interface That { transport: Transport }
|
||||
|
||||
export default class Internal {
|
||||
transport: Transport
|
||||
constructor (transport: Transport) {
|
||||
this.transport = transport
|
||||
}
|
||||
|
||||
async deleteDesiredNodes (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async deleteDesiredNodes (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async deleteDesiredNodes (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async deleteDesiredNodes (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = []
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
|
||||
const method = 'DELETE'
|
||||
const path = '/_internal/desired_nodes'
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async getDesiredNodes (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async getDesiredNodes (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async getDesiredNodes (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async getDesiredNodes (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = []
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
|
||||
const method = 'GET'
|
||||
const path = '/_internal/desired_nodes/_latest'
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async updateDesiredNodes (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async updateDesiredNodes (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async updateDesiredNodes (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async updateDesiredNodes (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = ['history_id', 'version']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
|
||||
const method = 'PUT'
|
||||
const path = `/_internal/desired_nodes/${encodeURIComponent(params.history_id.toString())}/${encodeURIComponent(params.version.toString())}`
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
}
|
||||
@ -87,10 +87,10 @@ export default class AsyncSearch {
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async status<TDocument = unknown> (this: That, params: T.AsyncSearchStatusRequest | TB.AsyncSearchStatusRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchStatusResponse<TDocument>>
|
||||
async status<TDocument = unknown> (this: That, params: T.AsyncSearchStatusRequest | TB.AsyncSearchStatusRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AsyncSearchStatusResponse<TDocument>, unknown>>
|
||||
async status<TDocument = unknown> (this: That, params: T.AsyncSearchStatusRequest | TB.AsyncSearchStatusRequest, options?: TransportRequestOptions): Promise<T.AsyncSearchStatusResponse<TDocument>>
|
||||
async status<TDocument = unknown> (this: That, params: T.AsyncSearchStatusRequest | TB.AsyncSearchStatusRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
async status (this: That, params: T.AsyncSearchStatusRequest | TB.AsyncSearchStatusRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.AsyncSearchStatusResponse>
|
||||
async status (this: That, params: T.AsyncSearchStatusRequest | TB.AsyncSearchStatusRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.AsyncSearchStatusResponse, unknown>>
|
||||
async status (this: That, params: T.AsyncSearchStatusRequest | TB.AsyncSearchStatusRequest, options?: TransportRequestOptions): Promise<T.AsyncSearchStatusResponse>
|
||||
async status (this: That, params: T.AsyncSearchStatusRequest | TB.AsyncSearchStatusRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = ['id']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
|
||||
@ -37,10 +37,10 @@ import * as T from '../types'
|
||||
import * as TB from '../typesWithBodyKey'
|
||||
interface That { transport: Transport }
|
||||
|
||||
export default async function BulkApi<TSource = unknown> (this: That, params: T.BulkRequest<TSource> | TB.BulkRequest<TSource>, options?: TransportRequestOptionsWithOutMeta): Promise<T.BulkResponse>
|
||||
export default async function BulkApi<TSource = unknown> (this: That, params: T.BulkRequest<TSource> | TB.BulkRequest<TSource>, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.BulkResponse, unknown>>
|
||||
export default async function BulkApi<TSource = unknown> (this: That, params: T.BulkRequest<TSource> | TB.BulkRequest<TSource>, options?: TransportRequestOptions): Promise<T.BulkResponse>
|
||||
export default async function BulkApi<TSource = unknown> (this: That, params: T.BulkRequest<TSource> | TB.BulkRequest<TSource>, options?: TransportRequestOptions): Promise<any> {
|
||||
export default async function BulkApi<TDocument = unknown, TPartialDocument = unknown> (this: That, params: T.BulkRequest<TDocument, TPartialDocument> | TB.BulkRequest<TDocument, TPartialDocument>, options?: TransportRequestOptionsWithOutMeta): Promise<T.BulkResponse>
|
||||
export default async function BulkApi<TDocument = unknown, TPartialDocument = unknown> (this: That, params: T.BulkRequest<TDocument, TPartialDocument> | TB.BulkRequest<TDocument, TPartialDocument>, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.BulkResponse, unknown>>
|
||||
export default async function BulkApi<TDocument = unknown, TPartialDocument = unknown> (this: That, params: T.BulkRequest<TDocument, TPartialDocument> | TB.BulkRequest<TDocument, TPartialDocument>, options?: TransportRequestOptions): Promise<T.BulkResponse>
|
||||
export default async function BulkApi<TDocument = unknown, TPartialDocument = unknown> (this: That, params: T.BulkRequest<TDocument, TPartialDocument> | TB.BulkRequest<TDocument, TPartialDocument>, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = ['index']
|
||||
const acceptedBody: string[] = ['operations']
|
||||
const querystring: Record<string, any> = {}
|
||||
|
||||
@ -114,7 +114,7 @@ export default class Eql {
|
||||
async search<TEvent = unknown> (this: That, params: T.EqlSearchRequest | TB.EqlSearchRequest, options?: TransportRequestOptions): Promise<T.EqlSearchResponse<TEvent>>
|
||||
async search<TEvent = unknown> (this: That, params: T.EqlSearchRequest | TB.EqlSearchRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = ['index']
|
||||
const acceptedBody: string[] = ['query', 'case_sensitive', 'event_category_field', 'tiebreaker_field', 'timestamp_field', 'fetch_size', 'filter', 'keep_alive', 'keep_on_completion', 'wait_for_completion_timeout', 'size', 'fields', 'result_position']
|
||||
const acceptedBody: string[] = ['query', 'case_sensitive', 'event_category_field', 'tiebreaker_field', 'timestamp_field', 'fetch_size', 'filter', 'keep_alive', 'keep_on_completion', 'wait_for_completion_timeout', 'size', 'fields', 'result_position', 'runtime_mappings']
|
||||
const querystring: Record<string, any> = {}
|
||||
// @ts-expect-error
|
||||
const userBody: any = params?.body
|
||||
|
||||
@ -37,10 +37,10 @@ import * as T from '../types'
|
||||
import * as TB from '../typesWithBodyKey'
|
||||
interface That { transport: Transport }
|
||||
|
||||
export default async function FieldCapsApi (this: That, params?: T.FieldCapsRequest | TB.FieldCapsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FieldCapsResponse>
|
||||
export default async function FieldCapsApi (this: That, params?: T.FieldCapsRequest | TB.FieldCapsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FieldCapsResponse, unknown>>
|
||||
export default async function FieldCapsApi (this: That, params?: T.FieldCapsRequest | TB.FieldCapsRequest, options?: TransportRequestOptions): Promise<T.FieldCapsResponse>
|
||||
export default async function FieldCapsApi (this: That, params?: T.FieldCapsRequest | TB.FieldCapsRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
export default async function FieldCapsApi (this: That, params: T.FieldCapsRequest | TB.FieldCapsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FieldCapsResponse>
|
||||
export default async function FieldCapsApi (this: That, params: T.FieldCapsRequest | TB.FieldCapsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FieldCapsResponse, unknown>>
|
||||
export default async function FieldCapsApi (this: That, params: T.FieldCapsRequest | TB.FieldCapsRequest, options?: TransportRequestOptions): Promise<T.FieldCapsResponse>
|
||||
export default async function FieldCapsApi (this: That, params: T.FieldCapsRequest | TB.FieldCapsRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = ['index']
|
||||
const acceptedBody: string[] = ['index_filter', 'runtime_mappings']
|
||||
const querystring: Record<string, any> = {}
|
||||
@ -53,7 +53,6 @@ export default async function FieldCapsApi (this: That, params?: T.FieldCapsRequ
|
||||
body = userBody != null ? { ...userBody } : undefined
|
||||
}
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedBody.includes(key)) {
|
||||
body = body ?? {}
|
||||
|
||||
@ -65,19 +65,24 @@ export default class Fleet {
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async msearch (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async msearch (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async msearch (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async msearch (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async msearch<TDocument = unknown> (this: That, params: T.FleetMsearchRequest | TB.FleetMsearchRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FleetMsearchResponse<TDocument>>
|
||||
async msearch<TDocument = unknown> (this: That, params: T.FleetMsearchRequest | TB.FleetMsearchRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FleetMsearchResponse<TDocument>, unknown>>
|
||||
async msearch<TDocument = unknown> (this: That, params: T.FleetMsearchRequest | TB.FleetMsearchRequest, options?: TransportRequestOptions): Promise<T.FleetMsearchResponse<TDocument>>
|
||||
async msearch<TDocument = unknown> (this: That, params: T.FleetMsearchRequest | TB.FleetMsearchRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = ['index']
|
||||
const acceptedBody: string[] = ['searches']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
// @ts-expect-error
|
||||
let body: any = params.body ?? undefined
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
if (acceptedBody.includes(key)) {
|
||||
// @ts-expect-error
|
||||
body = params[key]
|
||||
} else if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
@ -94,19 +99,31 @@ export default class Fleet {
|
||||
return await this.transport.request({ path, method, querystring, bulkBody: body }, options)
|
||||
}
|
||||
|
||||
async search (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async search (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async search (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async search (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async search<TDocument = unknown> (this: That, params: T.FleetSearchRequest | TB.FleetSearchRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.FleetSearchResponse<TDocument>>
|
||||
async search<TDocument = unknown> (this: That, params: T.FleetSearchRequest | TB.FleetSearchRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.FleetSearchResponse<TDocument>, unknown>>
|
||||
async search<TDocument = unknown> (this: That, params: T.FleetSearchRequest | TB.FleetSearchRequest, options?: TransportRequestOptions): Promise<T.FleetSearchResponse<TDocument>>
|
||||
async search<TDocument = unknown> (this: That, params: T.FleetSearchRequest | TB.FleetSearchRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = ['index']
|
||||
const acceptedBody: string[] = ['aggregations', 'aggs', 'collapse', 'explain', 'from', 'highlight', 'track_total_hits', 'indices_boost', 'docvalue_fields', 'min_score', 'post_filter', 'profile', 'query', 'rescore', 'script_fields', 'search_after', 'size', 'slice', 'sort', '_source', 'fields', 'suggest', 'terminate_after', 'timeout', 'track_scores', 'version', 'seq_no_primary_term', 'stored_fields', 'pit', 'runtime_mappings', 'stats']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
// @ts-expect-error
|
||||
const userBody: any = params?.body
|
||||
let body: Record<string, any> | string
|
||||
if (typeof userBody === 'string') {
|
||||
body = userBody
|
||||
} else {
|
||||
body = userBody != null ? { ...userBody } : undefined
|
||||
}
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
if (acceptedBody.includes(key)) {
|
||||
body = body ?? {}
|
||||
// @ts-expect-error
|
||||
body[key] = params[key]
|
||||
} else if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,19 +140,32 @@ export default class Ilm {
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async migrateToDataTiers (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async migrateToDataTiers (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async migrateToDataTiers (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async migrateToDataTiers (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async migrateToDataTiers (this: That, params?: T.IlmMigrateToDataTiersRequest | TB.IlmMigrateToDataTiersRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.IlmMigrateToDataTiersResponse>
|
||||
async migrateToDataTiers (this: That, params?: T.IlmMigrateToDataTiersRequest | TB.IlmMigrateToDataTiersRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.IlmMigrateToDataTiersResponse, unknown>>
|
||||
async migrateToDataTiers (this: That, params?: T.IlmMigrateToDataTiersRequest | TB.IlmMigrateToDataTiersRequest, options?: TransportRequestOptions): Promise<T.IlmMigrateToDataTiersResponse>
|
||||
async migrateToDataTiers (this: That, params?: T.IlmMigrateToDataTiersRequest | TB.IlmMigrateToDataTiersRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = []
|
||||
const acceptedBody: string[] = ['legacy_template_to_delete', 'node_attribute']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
// @ts-expect-error
|
||||
const userBody: any = params?.body
|
||||
let body: Record<string, any> | string
|
||||
if (typeof userBody === 'string') {
|
||||
body = userBody
|
||||
} else {
|
||||
body = userBody != null ? { ...userBody } : undefined
|
||||
}
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
if (acceptedBody.includes(key)) {
|
||||
body = body ?? {}
|
||||
// @ts-expect-error
|
||||
body[key] = params[key]
|
||||
} else if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
|
||||
@ -513,19 +513,19 @@ export default class Indices {
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async fieldUsageStats (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async fieldUsageStats (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async fieldUsageStats (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async fieldUsageStats (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async fieldUsageStats (this: That, params: T.IndicesFieldUsageStatsRequest | TB.IndicesFieldUsageStatsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.IndicesFieldUsageStatsResponse>
|
||||
async fieldUsageStats (this: That, params: T.IndicesFieldUsageStatsRequest | TB.IndicesFieldUsageStatsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.IndicesFieldUsageStatsResponse, unknown>>
|
||||
async fieldUsageStats (this: That, params: T.IndicesFieldUsageStatsRequest | TB.IndicesFieldUsageStatsRequest, options?: TransportRequestOptions): Promise<T.IndicesFieldUsageStatsResponse>
|
||||
async fieldUsageStats (this: That, params: T.IndicesFieldUsageStatsRequest | TB.IndicesFieldUsageStatsRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = ['index']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,10 +43,10 @@ export default class Monitoring {
|
||||
this.transport = transport
|
||||
}
|
||||
|
||||
async bulk<TSource = unknown> (this: That, params: T.MonitoringBulkRequest<TSource> | TB.MonitoringBulkRequest<TSource>, options?: TransportRequestOptionsWithOutMeta): Promise<T.MonitoringBulkResponse>
|
||||
async bulk<TSource = unknown> (this: That, params: T.MonitoringBulkRequest<TSource> | TB.MonitoringBulkRequest<TSource>, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.MonitoringBulkResponse, unknown>>
|
||||
async bulk<TSource = unknown> (this: That, params: T.MonitoringBulkRequest<TSource> | TB.MonitoringBulkRequest<TSource>, options?: TransportRequestOptions): Promise<T.MonitoringBulkResponse>
|
||||
async bulk<TSource = unknown> (this: That, params: T.MonitoringBulkRequest<TSource> | TB.MonitoringBulkRequest<TSource>, options?: TransportRequestOptions): Promise<any> {
|
||||
async bulk<TDocument = unknown, TPartialDocument = unknown> (this: That, params: T.MonitoringBulkRequest<TDocument, TPartialDocument> | TB.MonitoringBulkRequest<TDocument, TPartialDocument>, options?: TransportRequestOptionsWithOutMeta): Promise<T.MonitoringBulkResponse>
|
||||
async bulk<TDocument = unknown, TPartialDocument = unknown> (this: That, params: T.MonitoringBulkRequest<TDocument, TPartialDocument> | TB.MonitoringBulkRequest<TDocument, TPartialDocument>, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.MonitoringBulkResponse, unknown>>
|
||||
async bulk<TDocument = unknown, TPartialDocument = unknown> (this: That, params: T.MonitoringBulkRequest<TDocument, TPartialDocument> | TB.MonitoringBulkRequest<TDocument, TPartialDocument>, options?: TransportRequestOptions): Promise<T.MonitoringBulkResponse>
|
||||
async bulk<TDocument = unknown, TPartialDocument = unknown> (this: That, params: T.MonitoringBulkRequest<TDocument, TPartialDocument> | TB.MonitoringBulkRequest<TDocument, TPartialDocument>, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = ['type']
|
||||
const acceptedBody: string[] = ['operations']
|
||||
const querystring: Record<string, any> = {}
|
||||
|
||||
@ -43,19 +43,19 @@ export default class Nodes {
|
||||
this.transport = transport
|
||||
}
|
||||
|
||||
async clearRepositoriesMeteringArchive (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async clearRepositoriesMeteringArchive (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async clearRepositoriesMeteringArchive (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async clearRepositoriesMeteringArchive (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async clearRepositoriesMeteringArchive (this: That, params: T.NodesClearRepositoriesMeteringArchiveRequest | TB.NodesClearRepositoriesMeteringArchiveRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.NodesClearRepositoriesMeteringArchiveResponse>
|
||||
async clearRepositoriesMeteringArchive (this: That, params: T.NodesClearRepositoriesMeteringArchiveRequest | TB.NodesClearRepositoriesMeteringArchiveRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.NodesClearRepositoriesMeteringArchiveResponse, unknown>>
|
||||
async clearRepositoriesMeteringArchive (this: That, params: T.NodesClearRepositoriesMeteringArchiveRequest | TB.NodesClearRepositoriesMeteringArchiveRequest, options?: TransportRequestOptions): Promise<T.NodesClearRepositoriesMeteringArchiveResponse>
|
||||
async clearRepositoriesMeteringArchive (this: That, params: T.NodesClearRepositoriesMeteringArchiveRequest | TB.NodesClearRepositoriesMeteringArchiveRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = ['node_id', 'max_archive_version']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
@ -65,19 +65,19 @@ export default class Nodes {
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async getRepositoriesMeteringInfo (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async getRepositoriesMeteringInfo (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async getRepositoriesMeteringInfo (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async getRepositoriesMeteringInfo (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async getRepositoriesMeteringInfo (this: That, params: T.NodesGetRepositoriesMeteringInfoRequest | TB.NodesGetRepositoriesMeteringInfoRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.NodesGetRepositoriesMeteringInfoResponse>
|
||||
async getRepositoriesMeteringInfo (this: That, params: T.NodesGetRepositoriesMeteringInfoRequest | TB.NodesGetRepositoriesMeteringInfoRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.NodesGetRepositoriesMeteringInfoResponse, unknown>>
|
||||
async getRepositoriesMeteringInfo (this: That, params: T.NodesGetRepositoriesMeteringInfoRequest | TB.NodesGetRepositoriesMeteringInfoRequest, options?: TransportRequestOptions): Promise<T.NodesGetRepositoriesMeteringInfoResponse>
|
||||
async getRepositoriesMeteringInfo (this: That, params: T.NodesGetRepositoriesMeteringInfoRequest | TB.NodesGetRepositoriesMeteringInfoRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = ['node_id']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,10 +37,10 @@ import * as T from '../types'
|
||||
import * as TB from '../typesWithBodyKey'
|
||||
interface That { transport: Transport }
|
||||
|
||||
export default async function ReindexApi (this: That, params?: T.ReindexRequest | TB.ReindexRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ReindexResponse>
|
||||
export default async function ReindexApi (this: That, params?: T.ReindexRequest | TB.ReindexRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ReindexResponse, unknown>>
|
||||
export default async function ReindexApi (this: That, params?: T.ReindexRequest | TB.ReindexRequest, options?: TransportRequestOptions): Promise<T.ReindexResponse>
|
||||
export default async function ReindexApi (this: That, params?: T.ReindexRequest | TB.ReindexRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
export default async function ReindexApi (this: That, params: T.ReindexRequest | TB.ReindexRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.ReindexResponse>
|
||||
export default async function ReindexApi (this: That, params: T.ReindexRequest | TB.ReindexRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.ReindexResponse, unknown>>
|
||||
export default async function ReindexApi (this: That, params: T.ReindexRequest | TB.ReindexRequest, options?: TransportRequestOptions): Promise<T.ReindexResponse>
|
||||
export default async function ReindexApi (this: That, params: T.ReindexRequest | TB.ReindexRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = []
|
||||
const acceptedBody: string[] = ['conflicts', 'dest', 'max_docs', 'script', 'size', 'source']
|
||||
const querystring: Record<string, any> = {}
|
||||
@ -53,7 +53,6 @@ export default async function ReindexApi (this: That, params?: T.ReindexRequest
|
||||
body = userBody != null ? { ...userBody } : undefined
|
||||
}
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedBody.includes(key)) {
|
||||
body = body ?? {}
|
||||
|
||||
@ -43,10 +43,10 @@ export default class SearchableSnapshots {
|
||||
this.transport = transport
|
||||
}
|
||||
|
||||
async cacheStats (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async cacheStats (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async cacheStats (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async cacheStats (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async cacheStats (this: That, params?: T.SearchableSnapshotsCacheStatsRequest | TB.SearchableSnapshotsCacheStatsRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.SearchableSnapshotsCacheStatsResponse>
|
||||
async cacheStats (this: That, params?: T.SearchableSnapshotsCacheStatsRequest | TB.SearchableSnapshotsCacheStatsRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.SearchableSnapshotsCacheStatsResponse, unknown>>
|
||||
async cacheStats (this: That, params?: T.SearchableSnapshotsCacheStatsRequest | TB.SearchableSnapshotsCacheStatsRequest, options?: TransportRequestOptions): Promise<T.SearchableSnapshotsCacheStatsResponse>
|
||||
async cacheStats (this: That, params?: T.SearchableSnapshotsCacheStatsRequest | TB.SearchableSnapshotsCacheStatsRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = ['node_id']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
@ -56,6 +56,7 @@ export default class SearchableSnapshots {
|
||||
if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
|
||||
@ -436,10 +436,10 @@ export default class Security {
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async enrollKibana (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async enrollKibana (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async enrollKibana (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async enrollKibana (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async enrollKibana (this: That, params?: T.SecurityEnrollKibanaRequest | TB.SecurityEnrollKibanaRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.SecurityEnrollKibanaResponse>
|
||||
async enrollKibana (this: That, params?: T.SecurityEnrollKibanaRequest | TB.SecurityEnrollKibanaRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.SecurityEnrollKibanaResponse, unknown>>
|
||||
async enrollKibana (this: That, params?: T.SecurityEnrollKibanaRequest | TB.SecurityEnrollKibanaRequest, options?: TransportRequestOptions): Promise<T.SecurityEnrollKibanaResponse>
|
||||
async enrollKibana (this: That, params?: T.SecurityEnrollKibanaRequest | TB.SecurityEnrollKibanaRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = []
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
@ -449,6 +449,7 @@ export default class Security {
|
||||
if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
@ -458,10 +459,10 @@ export default class Security {
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async enrollNode (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async enrollNode (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async enrollNode (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async enrollNode (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async enrollNode (this: That, params?: T.SecurityEnrollNodeRequest | TB.SecurityEnrollNodeRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.SecurityEnrollNodeResponse>
|
||||
async enrollNode (this: That, params?: T.SecurityEnrollNodeRequest | TB.SecurityEnrollNodeRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.SecurityEnrollNodeResponse, unknown>>
|
||||
async enrollNode (this: That, params?: T.SecurityEnrollNodeRequest | TB.SecurityEnrollNodeRequest, options?: TransportRequestOptions): Promise<T.SecurityEnrollNodeResponse>
|
||||
async enrollNode (this: That, params?: T.SecurityEnrollNodeRequest | TB.SecurityEnrollNodeRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = []
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
@ -471,6 +472,7 @@ export default class Security {
|
||||
if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
@ -908,6 +910,72 @@ export default class Security {
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async oidcAuthenticate (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async oidcAuthenticate (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async oidcAuthenticate (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async oidcAuthenticate (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = []
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
|
||||
const method = 'POST'
|
||||
const path = '/_security/oidc/authenticate'
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async oidcLogout (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async oidcLogout (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async oidcLogout (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async oidcLogout (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = []
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
|
||||
const method = 'POST'
|
||||
const path = '/_security/oidc/logout'
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async oidcPrepareAuthentication (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async oidcPrepareAuthentication (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async oidcPrepareAuthentication (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async oidcPrepareAuthentication (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = []
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
|
||||
const method = 'POST'
|
||||
const path = '/_security/oidc/prepare'
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async putPrivileges (this: That, params: T.SecurityPutPrivilegesRequest | TB.SecurityPutPrivilegesRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.SecurityPutPrivilegesResponse>
|
||||
async putPrivileges (this: That, params: T.SecurityPutPrivilegesRequest | TB.SecurityPutPrivilegesRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.SecurityPutPrivilegesResponse, unknown>>
|
||||
async putPrivileges (this: That, params: T.SecurityPutPrivilegesRequest | TB.SecurityPutPrivilegesRequest, options?: TransportRequestOptions): Promise<T.SecurityPutPrivilegesResponse>
|
||||
@ -1072,19 +1140,31 @@ export default class Security {
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async samlAuthenticate (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async samlAuthenticate (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async samlAuthenticate (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async samlAuthenticate (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async samlAuthenticate (this: That, params: T.SecuritySamlAuthenticateRequest | TB.SecuritySamlAuthenticateRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.SecuritySamlAuthenticateResponse>
|
||||
async samlAuthenticate (this: That, params: T.SecuritySamlAuthenticateRequest | TB.SecuritySamlAuthenticateRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.SecuritySamlAuthenticateResponse, unknown>>
|
||||
async samlAuthenticate (this: That, params: T.SecuritySamlAuthenticateRequest | TB.SecuritySamlAuthenticateRequest, options?: TransportRequestOptions): Promise<T.SecuritySamlAuthenticateResponse>
|
||||
async samlAuthenticate (this: That, params: T.SecuritySamlAuthenticateRequest | TB.SecuritySamlAuthenticateRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = []
|
||||
const acceptedBody: string[] = ['content', 'ids', 'realm']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
// @ts-expect-error
|
||||
const userBody: any = params?.body
|
||||
let body: Record<string, any> | string
|
||||
if (typeof userBody === 'string') {
|
||||
body = userBody
|
||||
} else {
|
||||
body = userBody != null ? { ...userBody } : undefined
|
||||
}
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
if (acceptedBody.includes(key)) {
|
||||
body = body ?? {}
|
||||
// @ts-expect-error
|
||||
body[key] = params[key]
|
||||
} else if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
@ -1094,19 +1174,31 @@ export default class Security {
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async samlCompleteLogout (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async samlCompleteLogout (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async samlCompleteLogout (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async samlCompleteLogout (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async samlCompleteLogout (this: That, params: T.SecuritySamlCompleteLogoutRequest | TB.SecuritySamlCompleteLogoutRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.SecuritySamlCompleteLogoutResponse>
|
||||
async samlCompleteLogout (this: That, params: T.SecuritySamlCompleteLogoutRequest | TB.SecuritySamlCompleteLogoutRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.SecuritySamlCompleteLogoutResponse, unknown>>
|
||||
async samlCompleteLogout (this: That, params: T.SecuritySamlCompleteLogoutRequest | TB.SecuritySamlCompleteLogoutRequest, options?: TransportRequestOptions): Promise<T.SecuritySamlCompleteLogoutResponse>
|
||||
async samlCompleteLogout (this: That, params: T.SecuritySamlCompleteLogoutRequest | TB.SecuritySamlCompleteLogoutRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = []
|
||||
const acceptedBody: string[] = ['realm', 'ids', 'query_string', 'content']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
// @ts-expect-error
|
||||
const userBody: any = params?.body
|
||||
let body: Record<string, any> | string
|
||||
if (typeof userBody === 'string') {
|
||||
body = userBody
|
||||
} else {
|
||||
body = userBody != null ? { ...userBody } : undefined
|
||||
}
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
if (acceptedBody.includes(key)) {
|
||||
body = body ?? {}
|
||||
// @ts-expect-error
|
||||
body[key] = params[key]
|
||||
} else if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
@ -1116,19 +1208,31 @@ export default class Security {
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async samlInvalidate (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async samlInvalidate (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async samlInvalidate (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async samlInvalidate (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async samlInvalidate (this: That, params: T.SecuritySamlInvalidateRequest | TB.SecuritySamlInvalidateRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.SecuritySamlInvalidateResponse>
|
||||
async samlInvalidate (this: That, params: T.SecuritySamlInvalidateRequest | TB.SecuritySamlInvalidateRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.SecuritySamlInvalidateResponse, unknown>>
|
||||
async samlInvalidate (this: That, params: T.SecuritySamlInvalidateRequest | TB.SecuritySamlInvalidateRequest, options?: TransportRequestOptions): Promise<T.SecuritySamlInvalidateResponse>
|
||||
async samlInvalidate (this: That, params: T.SecuritySamlInvalidateRequest | TB.SecuritySamlInvalidateRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = []
|
||||
const acceptedBody: string[] = ['acs', 'query_string', 'realm']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
// @ts-expect-error
|
||||
const userBody: any = params?.body
|
||||
let body: Record<string, any> | string
|
||||
if (typeof userBody === 'string') {
|
||||
body = userBody
|
||||
} else {
|
||||
body = userBody != null ? { ...userBody } : undefined
|
||||
}
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
if (acceptedBody.includes(key)) {
|
||||
body = body ?? {}
|
||||
// @ts-expect-error
|
||||
body[key] = params[key]
|
||||
} else if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
@ -1138,19 +1242,31 @@ export default class Security {
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async samlLogout (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async samlLogout (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async samlLogout (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async samlLogout (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async samlLogout (this: That, params: T.SecuritySamlLogoutRequest | TB.SecuritySamlLogoutRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.SecuritySamlLogoutResponse>
|
||||
async samlLogout (this: That, params: T.SecuritySamlLogoutRequest | TB.SecuritySamlLogoutRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.SecuritySamlLogoutResponse, unknown>>
|
||||
async samlLogout (this: That, params: T.SecuritySamlLogoutRequest | TB.SecuritySamlLogoutRequest, options?: TransportRequestOptions): Promise<T.SecuritySamlLogoutResponse>
|
||||
async samlLogout (this: That, params: T.SecuritySamlLogoutRequest | TB.SecuritySamlLogoutRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = []
|
||||
const acceptedBody: string[] = ['token', 'refresh_token']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
// @ts-expect-error
|
||||
const userBody: any = params?.body
|
||||
let body: Record<string, any> | string
|
||||
if (typeof userBody === 'string') {
|
||||
body = userBody
|
||||
} else {
|
||||
body = userBody != null ? { ...userBody } : undefined
|
||||
}
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
if (acceptedBody.includes(key)) {
|
||||
body = body ?? {}
|
||||
// @ts-expect-error
|
||||
body[key] = params[key]
|
||||
} else if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
@ -1160,19 +1276,32 @@ export default class Security {
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async samlPrepareAuthentication (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async samlPrepareAuthentication (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async samlPrepareAuthentication (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async samlPrepareAuthentication (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async samlPrepareAuthentication (this: That, params?: T.SecuritySamlPrepareAuthenticationRequest | TB.SecuritySamlPrepareAuthenticationRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.SecuritySamlPrepareAuthenticationResponse>
|
||||
async samlPrepareAuthentication (this: That, params?: T.SecuritySamlPrepareAuthenticationRequest | TB.SecuritySamlPrepareAuthenticationRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.SecuritySamlPrepareAuthenticationResponse, unknown>>
|
||||
async samlPrepareAuthentication (this: That, params?: T.SecuritySamlPrepareAuthenticationRequest | TB.SecuritySamlPrepareAuthenticationRequest, options?: TransportRequestOptions): Promise<T.SecuritySamlPrepareAuthenticationResponse>
|
||||
async samlPrepareAuthentication (this: That, params?: T.SecuritySamlPrepareAuthenticationRequest | TB.SecuritySamlPrepareAuthenticationRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = []
|
||||
const acceptedBody: string[] = ['acs', 'realm', 'relay_state']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
// @ts-expect-error
|
||||
const userBody: any = params?.body
|
||||
let body: Record<string, any> | string
|
||||
if (typeof userBody === 'string') {
|
||||
body = userBody
|
||||
} else {
|
||||
body = userBody != null ? { ...userBody } : undefined
|
||||
}
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
if (acceptedBody.includes(key)) {
|
||||
body = body ?? {}
|
||||
// @ts-expect-error
|
||||
body[key] = params[key]
|
||||
} else if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
@ -1182,19 +1311,19 @@ export default class Security {
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async samlServiceProviderMetadata (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async samlServiceProviderMetadata (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async samlServiceProviderMetadata (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async samlServiceProviderMetadata (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async samlServiceProviderMetadata (this: That, params: T.SecuritySamlServiceProviderMetadataRequest | TB.SecuritySamlServiceProviderMetadataRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.SecuritySamlServiceProviderMetadataResponse>
|
||||
async samlServiceProviderMetadata (this: That, params: T.SecuritySamlServiceProviderMetadataRequest | TB.SecuritySamlServiceProviderMetadataRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.SecuritySamlServiceProviderMetadataResponse, unknown>>
|
||||
async samlServiceProviderMetadata (this: That, params: T.SecuritySamlServiceProviderMetadataRequest | TB.SecuritySamlServiceProviderMetadataRequest, options?: TransportRequestOptions): Promise<T.SecuritySamlServiceProviderMetadataResponse>
|
||||
async samlServiceProviderMetadata (this: That, params: T.SecuritySamlServiceProviderMetadataRequest | TB.SecuritySamlServiceProviderMetadataRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = ['realm_name']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,19 +77,19 @@ export default class Sql {
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async deleteAsync (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async deleteAsync (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async deleteAsync (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async deleteAsync (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async deleteAsync (this: That, params: T.SqlDeleteAsyncRequest | TB.SqlDeleteAsyncRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.SqlDeleteAsyncResponse>
|
||||
async deleteAsync (this: That, params: T.SqlDeleteAsyncRequest | TB.SqlDeleteAsyncRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.SqlDeleteAsyncResponse, unknown>>
|
||||
async deleteAsync (this: That, params: T.SqlDeleteAsyncRequest | TB.SqlDeleteAsyncRequest, options?: TransportRequestOptions): Promise<T.SqlDeleteAsyncResponse>
|
||||
async deleteAsync (this: That, params: T.SqlDeleteAsyncRequest | TB.SqlDeleteAsyncRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = ['id']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
@ -99,19 +99,19 @@ export default class Sql {
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async getAsync (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async getAsync (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async getAsync (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async getAsync (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async getAsync (this: That, params: T.SqlGetAsyncRequest | TB.SqlGetAsyncRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.SqlGetAsyncResponse>
|
||||
async getAsync (this: That, params: T.SqlGetAsyncRequest | TB.SqlGetAsyncRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.SqlGetAsyncResponse, unknown>>
|
||||
async getAsync (this: That, params: T.SqlGetAsyncRequest | TB.SqlGetAsyncRequest, options?: TransportRequestOptions): Promise<T.SqlGetAsyncResponse>
|
||||
async getAsync (this: That, params: T.SqlGetAsyncRequest | TB.SqlGetAsyncRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = ['id']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
@ -121,19 +121,19 @@ export default class Sql {
|
||||
return await this.transport.request({ path, method, querystring, body }, options)
|
||||
}
|
||||
|
||||
async getAsyncStatus (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
|
||||
async getAsyncStatus (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
|
||||
async getAsyncStatus (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<T.TODO>
|
||||
async getAsyncStatus (this: That, params?: T.TODO | TB.TODO, options?: TransportRequestOptions): Promise<any> {
|
||||
async getAsyncStatus (this: That, params: T.SqlGetAsyncStatusRequest | TB.SqlGetAsyncStatusRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.SqlGetAsyncStatusResponse>
|
||||
async getAsyncStatus (this: That, params: T.SqlGetAsyncStatusRequest | TB.SqlGetAsyncStatusRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.SqlGetAsyncStatusResponse, unknown>>
|
||||
async getAsyncStatus (this: That, params: T.SqlGetAsyncStatusRequest | TB.SqlGetAsyncStatusRequest, options?: TransportRequestOptions): Promise<T.SqlGetAsyncStatusResponse>
|
||||
async getAsyncStatus (this: That, params: T.SqlGetAsyncStatusRequest | TB.SqlGetAsyncStatusRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = ['id']
|
||||
const querystring: Record<string, any> = {}
|
||||
const body = undefined
|
||||
|
||||
params = params ?? {}
|
||||
for (const key in params) {
|
||||
if (acceptedPath.includes(key)) {
|
||||
continue
|
||||
} else if (key !== 'body') {
|
||||
// @ts-expect-error
|
||||
querystring[key] = params[key]
|
||||
}
|
||||
}
|
||||
@ -148,7 +148,7 @@ export default class Sql {
|
||||
async query (this: That, params?: T.SqlQueryRequest | TB.SqlQueryRequest, options?: TransportRequestOptions): Promise<T.SqlQueryResponse>
|
||||
async query (this: That, params?: T.SqlQueryRequest | TB.SqlQueryRequest, options?: TransportRequestOptions): Promise<any> {
|
||||
const acceptedPath: string[] = []
|
||||
const acceptedBody: string[] = ['columnar', 'cursor', 'fetch_size', 'filter', 'query', 'request_timeout', 'page_timeout', 'time_zone', 'field_multi_value_leniency']
|
||||
const acceptedBody: string[] = ['catalog', 'columnar', 'cursor', 'fetch_size', 'filter', 'query', 'request_timeout', 'page_timeout', 'time_zone', 'field_multi_value_leniency', 'runtime_mappings', 'wait_for_completion_timeout', 'params', 'keep_alive', 'keep_on_completion', 'index_using_frozen']
|
||||
const querystring: Record<string, any> = {}
|
||||
// @ts-expect-error
|
||||
const userBody: any = params?.body
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
// DO NOT MODIFY IT BY HAND. Instead, modify the source open api file,
|
||||
// and elastic/elastic-client-generator-js to regenerate this file again.
|
||||
|
||||
import InternalApi from './api/_internal'
|
||||
import AsyncSearchApi from './api/async_search'
|
||||
import AutoscalingApi from './api/autoscaling'
|
||||
import bulkApi from './api/bulk'
|
||||
@ -105,6 +106,7 @@ import XpackApi from './api/xpack'
|
||||
|
||||
export default interface API {
|
||||
new(): API
|
||||
Internal: InternalApi
|
||||
asyncSearch: AsyncSearchApi
|
||||
autoscaling: AutoscalingApi
|
||||
bulk: typeof bulkApi
|
||||
@ -183,6 +185,7 @@ export default interface API {
|
||||
xpack: XpackApi
|
||||
}
|
||||
|
||||
const kInternal = Symbol('Internal')
|
||||
const kAsyncSearch = Symbol('AsyncSearch')
|
||||
const kAutoscaling = Symbol('Autoscaling')
|
||||
const kCat = Symbol('Cat')
|
||||
@ -218,6 +221,7 @@ const kWatcher = Symbol('Watcher')
|
||||
const kXpack = Symbol('Xpack')
|
||||
|
||||
export default class API {
|
||||
[kInternal]: symbol | null
|
||||
[kAsyncSearch]: symbol | null
|
||||
[kAutoscaling]: symbol | null
|
||||
[kCat]: symbol | null
|
||||
@ -252,6 +256,7 @@ export default class API {
|
||||
[kWatcher]: symbol | null
|
||||
[kXpack]: symbol | null
|
||||
constructor () {
|
||||
this[kInternal] = null
|
||||
this[kAsyncSearch] = null
|
||||
this[kAutoscaling] = null
|
||||
this[kCat] = null
|
||||
@ -333,6 +338,9 @@ API.prototype.updateByQuery = updateByQueryApi
|
||||
API.prototype.updateByQueryRethrottle = updateByQueryRethrottleApi
|
||||
|
||||
Object.defineProperties(API.prototype, {
|
||||
Internal: {
|
||||
get () { return this[kInternal] === null ? (this[kInternal] = new InternalApi(this.transport)) : this[kInternal] }
|
||||
},
|
||||
asyncSearch: {
|
||||
get () { return this[kAsyncSearch] === null ? (this[kAsyncSearch] = new AsyncSearchApi(this.transport)) : this[kAsyncSearch] }
|
||||
},
|
||||
|
||||
@ -51,10 +51,15 @@ interface KibanaClient {
|
||||
helpers: Helpers
|
||||
child: (opts?: ClientOptions) => KibanaClient
|
||||
close: () => Promise<void>
|
||||
Internal: {
|
||||
deleteDesiredNodes: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
getDesiredNodes: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
updateDesiredNodes: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
}
|
||||
asyncSearch: {
|
||||
delete: <TContext = unknown>(params: T.AsyncSearchDeleteRequest| TB.AsyncSearchDeleteRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.AsyncSearchDeleteResponse, TContext>>
|
||||
get: <TDocument = unknown, TContext = unknown>(params: T.AsyncSearchGetRequest| TB.AsyncSearchGetRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.AsyncSearchGetResponse<TDocument>, TContext>>
|
||||
status: <TDocument = unknown, TContext = unknown>(params: T.AsyncSearchStatusRequest| TB.AsyncSearchStatusRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.AsyncSearchStatusResponse<TDocument>, TContext>>
|
||||
status: <TContext = unknown>(params: T.AsyncSearchStatusRequest| TB.AsyncSearchStatusRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.AsyncSearchStatusResponse, TContext>>
|
||||
submit: <TDocument = unknown, TContext = unknown>(params?: T.AsyncSearchSubmitRequest| TB.AsyncSearchSubmitRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.AsyncSearchSubmitResponse<TDocument>, TContext>>
|
||||
}
|
||||
autoscaling: {
|
||||
@ -63,7 +68,7 @@ interface KibanaClient {
|
||||
getAutoscalingPolicy: <TContext = unknown>(params: T.AutoscalingGetAutoscalingPolicyRequest| TB.AutoscalingGetAutoscalingPolicyRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.AutoscalingGetAutoscalingPolicyResponse, TContext>>
|
||||
putAutoscalingPolicy: <TContext = unknown>(params: T.AutoscalingPutAutoscalingPolicyRequest| TB.AutoscalingPutAutoscalingPolicyRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.AutoscalingPutAutoscalingPolicyResponse, TContext>>
|
||||
}
|
||||
bulk: <TSource = unknown, TContext = unknown>(params: T.BulkRequest<TSource>| TB.BulkRequest<TSource>, options?: TransportRequestOptions) => Promise<TransportResult<T.BulkResponse, TContext>>
|
||||
bulk: <TDocument = unknown, TPartialDocument = unknown, TContext = unknown>(params: T.BulkRequest<TDocument, TPartialDocument>| TB.BulkRequest<TDocument, TPartialDocument>, options?: TransportRequestOptions) => Promise<TransportResult<T.BulkResponse, TContext>>
|
||||
cat: {
|
||||
aliases: <TContext = unknown>(params?: T.CatAliasesRequest| TB.CatAliasesRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.CatAliasesResponse, TContext>>
|
||||
allocation: <TContext = unknown>(params?: T.CatAllocationRequest| TB.CatAllocationRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.CatAllocationResponse, TContext>>
|
||||
@ -156,11 +161,11 @@ interface KibanaClient {
|
||||
getFeatures: <TContext = unknown>(params?: T.FeaturesGetFeaturesRequest| TB.FeaturesGetFeaturesRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.FeaturesGetFeaturesResponse, TContext>>
|
||||
resetFeatures: <TContext = unknown>(params?: T.FeaturesResetFeaturesRequest| TB.FeaturesResetFeaturesRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.FeaturesResetFeaturesResponse, TContext>>
|
||||
}
|
||||
fieldCaps: <TContext = unknown>(params?: T.FieldCapsRequest| TB.FieldCapsRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.FieldCapsResponse, TContext>>
|
||||
fieldCaps: <TContext = unknown>(params: T.FieldCapsRequest| TB.FieldCapsRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.FieldCapsResponse, TContext>>
|
||||
fleet: {
|
||||
globalCheckpoints: <TContext = unknown>(params: T.FleetGlobalCheckpointsRequest| TB.FleetGlobalCheckpointsRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.FleetGlobalCheckpointsResponse, TContext>>
|
||||
msearch: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
search: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
msearch: <TDocument = unknown, TContext = unknown>(params: T.FleetMsearchRequest| TB.FleetMsearchRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.FleetMsearchResponse<TDocument>, TContext>>
|
||||
search: <TDocument = unknown, TContext = unknown>(params: T.FleetSearchRequest| TB.FleetSearchRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.FleetSearchResponse<TDocument>, TContext>>
|
||||
}
|
||||
get: <TDocument = unknown, TContext = unknown>(params: T.GetRequest| TB.GetRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.GetResponse<TDocument>, TContext>>
|
||||
getScript: <TContext = unknown>(params: T.GetScriptRequest| TB.GetScriptRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.GetScriptResponse, TContext>>
|
||||
@ -175,7 +180,7 @@ interface KibanaClient {
|
||||
explainLifecycle: <TContext = unknown>(params: T.IlmExplainLifecycleRequest| TB.IlmExplainLifecycleRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.IlmExplainLifecycleResponse, TContext>>
|
||||
getLifecycle: <TContext = unknown>(params?: T.IlmGetLifecycleRequest| TB.IlmGetLifecycleRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.IlmGetLifecycleResponse, TContext>>
|
||||
getStatus: <TContext = unknown>(params?: T.IlmGetStatusRequest| TB.IlmGetStatusRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.IlmGetStatusResponse, TContext>>
|
||||
migrateToDataTiers: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
migrateToDataTiers: <TContext = unknown>(params?: T.IlmMigrateToDataTiersRequest| TB.IlmMigrateToDataTiersRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.IlmMigrateToDataTiersResponse, TContext>>
|
||||
moveToStep: <TContext = unknown>(params: T.IlmMoveToStepRequest| TB.IlmMoveToStepRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.IlmMoveToStepResponse, TContext>>
|
||||
putLifecycle: <TContext = unknown>(params: T.IlmPutLifecycleRequest| TB.IlmPutLifecycleRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.IlmPutLifecycleResponse, TContext>>
|
||||
removePolicy: <TContext = unknown>(params: T.IlmRemovePolicyRequest| TB.IlmRemovePolicyRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.IlmRemovePolicyResponse, TContext>>
|
||||
@ -203,7 +208,7 @@ interface KibanaClient {
|
||||
existsAlias: <TContext = unknown>(params: T.IndicesExistsAliasRequest| TB.IndicesExistsAliasRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.IndicesExistsAliasResponse, TContext>>
|
||||
existsIndexTemplate: <TContext = unknown>(params: T.IndicesExistsIndexTemplateRequest| TB.IndicesExistsIndexTemplateRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.IndicesExistsIndexTemplateResponse, TContext>>
|
||||
existsTemplate: <TContext = unknown>(params: T.IndicesExistsTemplateRequest| TB.IndicesExistsTemplateRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.IndicesExistsTemplateResponse, TContext>>
|
||||
fieldUsageStats: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
fieldUsageStats: <TContext = unknown>(params: T.IndicesFieldUsageStatsRequest| TB.IndicesFieldUsageStatsRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.IndicesFieldUsageStatsResponse, TContext>>
|
||||
flush: <TContext = unknown>(params?: T.IndicesFlushRequest| TB.IndicesFlushRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.IndicesFlushResponse, TContext>>
|
||||
forcemerge: <TContext = unknown>(params?: T.IndicesForcemergeRequest| TB.IndicesForcemergeRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.IndicesForcemergeResponse, TContext>>
|
||||
get: <TContext = unknown>(params: T.IndicesGetRequest| TB.IndicesGetRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.IndicesGetResponse, TContext>>
|
||||
@ -342,14 +347,14 @@ interface KibanaClient {
|
||||
validateDetector: <TContext = unknown>(params?: T.MlValidateDetectorRequest| TB.MlValidateDetectorRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.MlValidateDetectorResponse, TContext>>
|
||||
}
|
||||
monitoring: {
|
||||
bulk: <TSource = unknown, TContext = unknown>(params: T.MonitoringBulkRequest<TSource>| TB.MonitoringBulkRequest<TSource>, options?: TransportRequestOptions) => Promise<TransportResult<T.MonitoringBulkResponse, TContext>>
|
||||
bulk: <TDocument = unknown, TPartialDocument = unknown, TContext = unknown>(params: T.MonitoringBulkRequest<TDocument, TPartialDocument>| TB.MonitoringBulkRequest<TDocument, TPartialDocument>, options?: TransportRequestOptions) => Promise<TransportResult<T.MonitoringBulkResponse, TContext>>
|
||||
}
|
||||
msearch: <TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>, TContext = unknown>(params?: T.MsearchRequest| TB.MsearchRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.MsearchResponse<TDocument, TAggregations>, TContext>>
|
||||
msearchTemplate: <TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>, TContext = unknown>(params?: T.MsearchTemplateRequest| TB.MsearchTemplateRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.MsearchTemplateResponse<TDocument, TAggregations>, TContext>>
|
||||
mtermvectors: <TContext = unknown>(params?: T.MtermvectorsRequest| TB.MtermvectorsRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.MtermvectorsResponse, TContext>>
|
||||
nodes: {
|
||||
clearRepositoriesMeteringArchive: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
getRepositoriesMeteringInfo: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
clearRepositoriesMeteringArchive: <TContext = unknown>(params: T.NodesClearRepositoriesMeteringArchiveRequest| TB.NodesClearRepositoriesMeteringArchiveRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.NodesClearRepositoriesMeteringArchiveResponse, TContext>>
|
||||
getRepositoriesMeteringInfo: <TContext = unknown>(params: T.NodesGetRepositoriesMeteringInfoRequest| TB.NodesGetRepositoriesMeteringInfoRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.NodesGetRepositoriesMeteringInfoResponse, TContext>>
|
||||
hotThreads: <TContext = unknown>(params?: T.NodesHotThreadsRequest| TB.NodesHotThreadsRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.NodesHotThreadsResponse, TContext>>
|
||||
info: <TContext = unknown>(params?: T.NodesInfoRequest| TB.NodesInfoRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.NodesInfoResponse, TContext>>
|
||||
reloadSecureSettings: <TContext = unknown>(params?: T.NodesReloadSecureSettingsRequest| TB.NodesReloadSecureSettingsRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.NodesReloadSecureSettingsResponse, TContext>>
|
||||
@ -381,7 +386,7 @@ interface KibanaClient {
|
||||
searchShards: <TContext = unknown>(params?: T.SearchShardsRequest| TB.SearchShardsRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SearchShardsResponse, TContext>>
|
||||
searchTemplate: <TDocument = unknown, TContext = unknown>(params?: T.SearchTemplateRequest| TB.SearchTemplateRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SearchTemplateResponse<TDocument>, TContext>>
|
||||
searchableSnapshots: {
|
||||
cacheStats: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
cacheStats: <TContext = unknown>(params?: T.SearchableSnapshotsCacheStatsRequest| TB.SearchableSnapshotsCacheStatsRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SearchableSnapshotsCacheStatsResponse, TContext>>
|
||||
clearCache: <TContext = unknown>(params?: T.SearchableSnapshotsClearCacheRequest| TB.SearchableSnapshotsClearCacheRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SearchableSnapshotsClearCacheResponse, TContext>>
|
||||
mount: <TContext = unknown>(params: T.SearchableSnapshotsMountRequest| TB.SearchableSnapshotsMountRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SearchableSnapshotsMountResponse, TContext>>
|
||||
stats: <TContext = unknown>(params?: T.SearchableSnapshotsStatsRequest| TB.SearchableSnapshotsStatsRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SearchableSnapshotsStatsResponse, TContext>>
|
||||
@ -403,8 +408,8 @@ interface KibanaClient {
|
||||
deleteUser: <TContext = unknown>(params: T.SecurityDeleteUserRequest| TB.SecurityDeleteUserRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecurityDeleteUserResponse, TContext>>
|
||||
disableUser: <TContext = unknown>(params: T.SecurityDisableUserRequest| TB.SecurityDisableUserRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecurityDisableUserResponse, TContext>>
|
||||
enableUser: <TContext = unknown>(params: T.SecurityEnableUserRequest| TB.SecurityEnableUserRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecurityEnableUserResponse, TContext>>
|
||||
enrollKibana: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
enrollNode: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
enrollKibana: <TContext = unknown>(params?: T.SecurityEnrollKibanaRequest| TB.SecurityEnrollKibanaRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecurityEnrollKibanaResponse, TContext>>
|
||||
enrollNode: <TContext = unknown>(params?: T.SecurityEnrollNodeRequest| TB.SecurityEnrollNodeRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecurityEnrollNodeResponse, TContext>>
|
||||
getApiKey: <TContext = unknown>(params?: T.SecurityGetApiKeyRequest| TB.SecurityGetApiKeyRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecurityGetApiKeyResponse, TContext>>
|
||||
getBuiltinPrivileges: <TContext = unknown>(params?: T.SecurityGetBuiltinPrivilegesRequest| TB.SecurityGetBuiltinPrivilegesRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecurityGetBuiltinPrivilegesResponse, TContext>>
|
||||
getPrivileges: <TContext = unknown>(params?: T.SecurityGetPrivilegesRequest| TB.SecurityGetPrivilegesRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecurityGetPrivilegesResponse, TContext>>
|
||||
@ -419,17 +424,20 @@ interface KibanaClient {
|
||||
hasPrivileges: <TContext = unknown>(params?: T.SecurityHasPrivilegesRequest| TB.SecurityHasPrivilegesRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecurityHasPrivilegesResponse, TContext>>
|
||||
invalidateApiKey: <TContext = unknown>(params?: T.SecurityInvalidateApiKeyRequest| TB.SecurityInvalidateApiKeyRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecurityInvalidateApiKeyResponse, TContext>>
|
||||
invalidateToken: <TContext = unknown>(params?: T.SecurityInvalidateTokenRequest| TB.SecurityInvalidateTokenRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecurityInvalidateTokenResponse, TContext>>
|
||||
oidcAuthenticate: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
oidcLogout: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
oidcPrepareAuthentication: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
putPrivileges: <TContext = unknown>(params?: T.SecurityPutPrivilegesRequest| TB.SecurityPutPrivilegesRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecurityPutPrivilegesResponse, TContext>>
|
||||
putRole: <TContext = unknown>(params: T.SecurityPutRoleRequest| TB.SecurityPutRoleRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecurityPutRoleResponse, TContext>>
|
||||
putRoleMapping: <TContext = unknown>(params: T.SecurityPutRoleMappingRequest| TB.SecurityPutRoleMappingRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecurityPutRoleMappingResponse, TContext>>
|
||||
putUser: <TContext = unknown>(params: T.SecurityPutUserRequest| TB.SecurityPutUserRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecurityPutUserResponse, TContext>>
|
||||
queryApiKeys: <TContext = unknown>(params?: T.SecurityQueryApiKeysRequest| TB.SecurityQueryApiKeysRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecurityQueryApiKeysResponse, TContext>>
|
||||
samlAuthenticate: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
samlCompleteLogout: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
samlInvalidate: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
samlLogout: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
samlPrepareAuthentication: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
samlServiceProviderMetadata: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
samlAuthenticate: <TContext = unknown>(params?: T.SecuritySamlAuthenticateRequest| TB.SecuritySamlAuthenticateRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecuritySamlAuthenticateResponse, TContext>>
|
||||
samlCompleteLogout: <TContext = unknown>(params?: T.SecuritySamlCompleteLogoutRequest| TB.SecuritySamlCompleteLogoutRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecuritySamlCompleteLogoutResponse, TContext>>
|
||||
samlInvalidate: <TContext = unknown>(params?: T.SecuritySamlInvalidateRequest| TB.SecuritySamlInvalidateRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecuritySamlInvalidateResponse, TContext>>
|
||||
samlLogout: <TContext = unknown>(params?: T.SecuritySamlLogoutRequest| TB.SecuritySamlLogoutRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecuritySamlLogoutResponse, TContext>>
|
||||
samlPrepareAuthentication: <TContext = unknown>(params?: T.SecuritySamlPrepareAuthenticationRequest| TB.SecuritySamlPrepareAuthenticationRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecuritySamlPrepareAuthenticationResponse, TContext>>
|
||||
samlServiceProviderMetadata: <TContext = unknown>(params: T.SecuritySamlServiceProviderMetadataRequest| TB.SecuritySamlServiceProviderMetadataRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SecuritySamlServiceProviderMetadataResponse, TContext>>
|
||||
}
|
||||
shutdown: {
|
||||
deleteNode: <TContext = unknown>(params: T.ShutdownDeleteNodeRequest| TB.ShutdownDeleteNodeRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.ShutdownDeleteNodeResponse, TContext>>
|
||||
@ -463,9 +471,9 @@ interface KibanaClient {
|
||||
}
|
||||
sql: {
|
||||
clearCursor: <TContext = unknown>(params?: T.SqlClearCursorRequest| TB.SqlClearCursorRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SqlClearCursorResponse, TContext>>
|
||||
deleteAsync: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
getAsync: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
getAsyncStatus: <TContext = unknown>(params?: T.TODO, options?: TransportRequestOptions) => Promise<TransportResult<T.TODO, unknown>>
|
||||
deleteAsync: <TContext = unknown>(params: T.SqlDeleteAsyncRequest| TB.SqlDeleteAsyncRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SqlDeleteAsyncResponse, TContext>>
|
||||
getAsync: <TContext = unknown>(params: T.SqlGetAsyncRequest| TB.SqlGetAsyncRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SqlGetAsyncResponse, TContext>>
|
||||
getAsyncStatus: <TContext = unknown>(params: T.SqlGetAsyncStatusRequest| TB.SqlGetAsyncStatusRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SqlGetAsyncStatusResponse, TContext>>
|
||||
query: <TContext = unknown>(params?: T.SqlQueryRequest| TB.SqlQueryRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SqlQueryResponse, TContext>>
|
||||
translate: <TContext = unknown>(params?: T.SqlTranslateRequest| TB.SqlTranslateRequest, options?: TransportRequestOptions) => Promise<TransportResult<T.SqlTranslateResponse, TContext>>
|
||||
}
|
||||
|
||||
1681
src/api/types.ts
1681
src/api/types.ts
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -251,7 +251,12 @@ export default class Client extends API {
|
||||
context: options.context,
|
||||
productCheck: 'Elasticsearch',
|
||||
maxResponseSize: options.maxResponseSize,
|
||||
maxCompressedResponseSize: options.maxCompressedResponseSize
|
||||
maxCompressedResponseSize: options.maxCompressedResponseSize,
|
||||
vendoredHeaders: {
|
||||
jsonContentType: 'application/vnd.elasticsearch+json; compatible-with=8',
|
||||
ndjsonContentType: 'application/vnd.elasticsearch+x-ndjson; compatible-with=8',
|
||||
accept: 'application/vnd.elasticsearch+json; compatible-with=8,text/plain'
|
||||
}
|
||||
})
|
||||
|
||||
this.helpers = new Helpers({
|
||||
|
||||
@ -356,21 +356,24 @@ export default class Helpers {
|
||||
let loadedOperations = 0
|
||||
timeoutRef = setTimeout(onFlushTimeout, flushInterval) // eslint-disable-line
|
||||
|
||||
for await (const operation of operationsStream) {
|
||||
timeoutRef.refresh()
|
||||
loadedOperations += 1
|
||||
msearchBody.push(operation[0], operation[1])
|
||||
callbacks.push(operation[2])
|
||||
if (loadedOperations >= operations) {
|
||||
const send = await semaphore()
|
||||
send(msearchBody.slice(), callbacks.slice())
|
||||
msearchBody.length = 0
|
||||
callbacks.length = 0
|
||||
loadedOperations = 0
|
||||
try {
|
||||
for await (const operation of operationsStream) {
|
||||
timeoutRef.refresh()
|
||||
loadedOperations += 1
|
||||
msearchBody.push(operation[0], operation[1])
|
||||
callbacks.push(operation[2])
|
||||
if (loadedOperations >= operations) {
|
||||
const send = await semaphore()
|
||||
send(msearchBody.slice(), callbacks.slice())
|
||||
msearchBody.length = 0
|
||||
callbacks.length = 0
|
||||
loadedOperations = 0
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
clearTimeout(timeoutRef)
|
||||
}
|
||||
|
||||
clearTimeout(timeoutRef)
|
||||
// In some cases the previos http call does not have finished,
|
||||
// or we didn't reach the flush bytes threshold, so we force one last operation.
|
||||
if (loadedOperations > 0) {
|
||||
|
||||
Reference in New Issue
Block a user