You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`node` or `nodes`| The Elasticsearch endpoint to use.<br> It can be a single string or an array of strings:<br><br>```js<br>node: 'http://localhost:9200'<br>```<br><br>Or it can be an object (or an array of objects) that represents the node:<br><br>```js<br>node: {<br> url: new URL('http://localhost:9200'),<br> tls: 'tls options',<br> agent: 'http agent options',<br> id: 'custom node id',<br> headers: { 'custom': 'headers' }<br> roles: {<br> master: true,<br> data: true,<br> ingest: true,<br> ml: false<br> }<br>}<br>```<br> |
24
-
|`auth`| Your authentication data. You can use both basic authentication and [ApiKey](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-api-key).<br> See [Authentication](/reference/connecting.md#authentication) for more details.<br> *Default:*`null`<br><br>Basic authentication:<br><br>```js<br>auth: {<br> username: 'elastic',<br> password: 'changeme'<br>}<br>```<br><br>[ApiKey](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-api-key) authentication:<br><br>```js<br>auth: {<br> apiKey: 'base64EncodedKey'<br>}<br>```<br><br>Bearer authentication, useful for [service account tokens](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-service-token). Be aware that it does not handle automatic token refresh:<br><br>```js<br>auth: {<br> bearer: 'token'<br>}<br>```<br> |
25
-
|`maxRetries`|`number` - Max number of retries for each request.<br>*Default:*`3`|
26
-
|`requestTimeout`|`number` - Max request timeout in milliseconds for each request.<br>*Default:* No value |
27
-
|`pingTimeout`|`number` - Max ping request timeout in milliseconds for each request.<br>*Default:*`3000`|
28
-
|`sniffInterval`|`number, boolean` - Perform a sniff operation every `n` milliseconds. Sniffing might not be the best solution for you, take a look [here](https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how) to know more.<br>*Default:*`false`|
29
-
|`sniffOnStart`|`boolean` - Perform a sniff once the client is started. Sniffing might not be the best solution for you, take a look [here](https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how) to know more.<br>*Default:*`false`|
30
-
|`sniffEndpoint`|`string` - Endpoint to ping during a sniff.<br>*Default:*`'_nodes/_all/http'`|
31
-
|`sniffOnConnectionFault`|`boolean` - Perform a sniff on connection fault. Sniffing might not be the best solution for you, take a look [here](https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how) to know more.<br>*Default:*`false`|
32
-
|`resurrectStrategy`|`string` - Configure the node resurrection strategy.<br>*Options:*`'ping'`, `'optimistic'`, `'none'`<br>*Default:*`'ping'`|
33
-
|`suggestCompression`|`boolean` - Adds `accept-encoding` header to every request.<br>*Default:*`false`|
34
-
|`compression`|`string, boolean` - Enables gzip request body compression.<br>*Options:*`'gzip'`, `false`<br>*Default:*`false`|
|`proxy`|`string, URL` - If you are using an http(s) proxy, you can put its url here. The client will automatically handle the connection to it.<br> *Default:*`null`<br><br>```js<br>const client = new Client({<br> node: 'http://localhost:9200',<br> proxy: 'http://localhost:8080'<br>})<br><br>const client = new Client({<br> node: 'http://localhost:9200',<br> proxy: 'http://user:pwd@localhost:8080'<br>})<br>```<br> |
37
-
|`agent`|`http.AgentOptions, function` - http agent [options](https://nodejs.org/api/http.md#http_new_agent_options), or a function that returns an actual http agent instance. If you want to disable the http agent use entirely (and disable the `keep-alive` feature), set the agent to `false`.<br> *Default:*`null`<br><br>```js<br>const client = new Client({<br> node: 'http://localhost:9200',<br> agent: { agent: 'options' }<br>})<br><br>const client = new Client({<br> node: 'http://localhost:9200',<br> // the function takes as parameter the option<br> // object passed to the Connection constructor<br> agent: (opts) => new CustomAgent()<br>})<br><br>const client = new Client({<br> node: 'http://localhost:9200',<br> // Disable agent and keep-alive<br> agent: false<br>})<br>```<br> |
38
-
|`nodeFilter`|`function` - Filters which node not to use for a request.<br> *Default:*<br><br>```js<br>function defaultNodeFilter (node) {<br> // avoid master only nodes<br> if (node.roles.master === true &&<br> node.roles.data === false &&<br> node.roles.ingest === false) {<br> return false<br> }<br> return true<br>}<br>```<br> |
|`generateRequestId`|`function` - function to generate the request id for every request, it takes two parameters, the request parameters and options.<br> By default it generates an incremental integer for every request.<br> *Custom function example:*<br><br>```js<br>function generateRequestId (params, options) {<br> // your id generation logic<br> // must be syncronous<br> return 'id'<br>}<br>```<br> |
41
-
|`name`|`string, symbol` - The name to identify the client instance in the events.<br>*Default:*`elasticsearch-js`|
42
-
|`opaqueIdPrefix`|`string` - A string that will be use to prefix any `X-Opaque-Id` header.<br>See [`X-Opaque-Id` support](/reference/observability.md#_x_opaque_id_support) for more details.<br>_Default:*`null`|
43
-
|`headers`|`object` - A set of custom headers to send in every request.<br>*Default:*`{}`|
44
-
|`context`|`object` - A custom object that you can use for observability in your events.It will be merged with the API level context option.<br>*Default:*`null`|
45
-
|`enableMetaHeader`|`boolean` - If true, adds an header named `'x-elastic-client-meta'`, containing some minimal telemetry data,such as the client and platform version.<br>*Default:*`true`|
46
-
|`cloud`|`object` - Custom configuration for connecting to [Elastic Cloud](https://cloud.elastic.co). See [Authentication](/reference/connecting.md) for more details.<br> *Default:*`null`<br> *Cloud configuration example:*<br><br>```js<br>const client = new Client({<br> cloud: {<br> id: '<cloud-id>'<br> },<br> auth: {<br> username: 'elastic',<br> password: 'changeme'<br> }<br>})<br>```<br> |
47
-
|`disablePrototypePoisoningProtection`|`boolean`, `'proto'`, `'constructor'` - The client can protect you against prototype poisoning attacks. Read [this article](https://web.archive.org/web/20200319091159/https://hueniverse.com/square-brackets-are-the-enemy-ff5b9fd8a3e8?gi=184a27ee2a08) to learn more about this security concern. If needed, you can enable prototype poisoning protection entirely (`false`) or one of the two checks (`'proto'` or `'constructor'`). For performance reasons, it is disabled by default. Read the `secure-json-parse`[documentation](https://github.com/fastify/secure-json-parse) to learn more.<br>*Default:*`true`|
48
-
|`caFingerprint`|`string` - If configured, verify that the fingerprint of the CA certificate that has signed the certificate of the server matches the supplied fingerprint. Only accepts SHA256 digest fingerprints.<br>*Default:*`null`|
49
-
|`maxResponseSize`|`number` - When configured, it verifies that the uncompressed 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_STRING_LENGTH<br>*Default:*`null`|
50
-
|`maxCompressedResponseSize`|`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_LENGTH<br>*Default:*`null`|
|`node` or `nodes`| The Elasticsearch endpoint to use. It can be a single string or an array of strings: |
24
+
25
+
```js
26
+
node:"http://localhost:9200";
27
+
```
28
+
29
+
Or it can be an object (or an array of objects) that represents the node:
30
+
31
+
```js
32
+
node: {
33
+
url:newURL('http://localhost:9200'),
34
+
tls:'tls options',
35
+
agent:'http agent options',
36
+
id:'custom node id',
37
+
headers: { 'custom':'headers' }
38
+
roles: {
39
+
master:true,
40
+
data:true,
41
+
ingest:true,
42
+
ml:false
43
+
}
44
+
}
45
+
```
46
+
47
+
|
48
+
| `auth` | Your authentication data. You can use both basic authentication and [ApiKey](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-api-key).
49
+
See [Authentication](/reference/connecting.md#authentication) for more details.
Bearer authentication, useful for [service account tokens](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-service-token). Be aware that it does not handle automatic token refresh:
70
+
71
+
```js
72
+
auth: {
73
+
bearer:"token";
74
+
}
75
+
```
76
+
77
+
|
78
+
| `maxRetries` | `number` - Max number of retries for each request.
79
+
_Default:_`3` |
80
+
| `requestTimeout` | `number` - Max request timeout in milliseconds for each request.
81
+
_Default:_ No value |
82
+
| `pingTimeout` | `number` - Max ping request timeout in milliseconds for each request.
83
+
_Default:_`3000` |
84
+
| `sniffInterval` | `number, boolean` - Perform a sniff operation every `n` milliseconds. Sniffing might not be the best solution for you, take a look [here](https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how) to know more.
85
+
_Default:_`false` |
86
+
| `sniffOnStart` | `boolean` - Perform a sniff once the client is started. Sniffing might not be the best solution for you, take a look [here](https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how) to know more.
87
+
_Default:_`false` |
88
+
| `sniffEndpoint` | `string` - Endpoint to ping during a sniff.
89
+
_Default:_`'_nodes/_all/http'` |
90
+
| `sniffOnConnectionFault` | `boolean` - Perform a sniff on connection fault. Sniffing might not be the best solution for you, take a look [here](https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how) to know more.
91
+
_Default:_`false` |
92
+
| `resurrectStrategy` | `string` - Configure the node resurrection strategy.
93
+
_Options:_`'ping'`, `'optimistic'`, `'none'`
94
+
_Default:_`'ping'` |
95
+
| `suggestCompression` | `boolean` - Adds `accept-encoding` header to every request.
| `proxy` | `string, URL` - If you are using an http(s) proxy, you can put its url here. The client will automatically handle the connection to it.
103
+
_Default:_`null`
104
+
105
+
```js
106
+
constclient=newClient({
107
+
node:"http://localhost:9200",
108
+
proxy:"http://localhost:8080",
109
+
});
110
+
111
+
constclient=newClient({
112
+
node:"http://localhost:9200",
113
+
proxy:"http://user:pwd@localhost:8080",
114
+
});
115
+
```
116
+
117
+
|
118
+
| `agent` | `http.AgentOptions, function` - http agent [options](https://nodejs.org/api/http.md#http_new_agent_options), or a function that returns an actual http agent instance. If you want to disable the http agent use entirely (and disable the `keep-alive` feature), set the agent to `false`.
119
+
_Default:_`null`
120
+
121
+
```js
122
+
constclient=newClient({
123
+
node:"http://localhost:9200",
124
+
agent: { agent:"options" },
125
+
});
126
+
127
+
constclient=newClient({
128
+
node:"http://localhost:9200",
129
+
// the function takes as parameter the option
130
+
// object passed to the Connection constructor
131
+
agent: (opts) =>newCustomAgent(),
132
+
});
133
+
134
+
constclient=newClient({
135
+
node:"http://localhost:9200",
136
+
// Disable agent and keep-alive
137
+
agent:false,
138
+
});
139
+
```
140
+
141
+
|
142
+
143
+
| `nodeFilter` | `function` - Filters which node not to use for a request.
_Options:_`'round-robin'`, `'random'`, custom function
153
+
_Default:_`'round-robin'`
154
+
_Custom function example:_
155
+
156
+
```js
157
+
functionnodeSelector(connections) {
158
+
constindex=calculateIndex();
159
+
return connections[index];
160
+
}
161
+
```
162
+
163
+
|
164
+
| `generateRequestId` | `function` - function to generate the request id for every request, it takes two parameters, the request parameters and options.
165
+
By default it generates an incremental integer for every request.
166
+
_Custom function example:_
167
+
168
+
```js
169
+
functiongenerateRequestId(params, options) {
170
+
// your id generation logic
171
+
// must be syncronous
172
+
return"id";
173
+
}
174
+
```
175
+
176
+
|
177
+
| `name` | `string, symbol` - The name to identify the client instance in the events.
178
+
_Default:_`elasticsearch-js` |
179
+
| `opaqueIdPrefix` | `string` - A string that will be use to prefix any `X-Opaque-Id` header.
180
+
See [`X-Opaque-Id` support](/reference/observability.md#_x_opaque_id_support) for more details.
181
+
\_Default:*`null` |
182
+
| `headers` | `object` - A set of custom headers to send in every request.
183
+
_Default:_`{}` |
184
+
| `context` | `object` - A custom object that you can use for observability in your events.It will be merged with the API level context option.
185
+
_Default:_`null` |
186
+
| `enableMetaHeader` | `boolean` - If true, adds an header named `'x-elastic-client-meta'`, containing some minimal telemetry data,such as the client and platform version.
187
+
_Default:_`true` |
188
+
| `cloud` | `object` - Custom configuration for connecting to [Elastic Cloud](https://cloud.elastic.co). See [Authentication](/reference/connecting.md) for more details.
189
+
_Default:_`null`
190
+
*Cloud configuration example:\*
191
+
192
+
```js
193
+
constclient=newClient({
194
+
cloud: {
195
+
id:"<cloud-id>",
196
+
},
197
+
auth: {
198
+
username:"elastic",
199
+
password:"changeme",
200
+
},
201
+
});
202
+
```
51
203
204
+
|
205
+
| `disablePrototypePoisoningProtection` | `boolean`, `'proto'`, `'constructor'` - The client can protect you against prototype poisoning attacks. Read [this article](https://web.archive.org/web/20200319091159/https://hueniverse.com/square-brackets-are-the-enemy-ff5b9fd8a3e8?gi=184a27ee2a08) to learn more about this security concern. If needed, you can enable prototype poisoning protection entirely (`false`) or one of the two checks (`'proto'` or `'constructor'`). For performance reasons, it is disabled by default. Read the `secure-json-parse`[documentation](https://github.com/fastify/secure-json-parse) to learn more.
206
+
_Default:_`true` |
207
+
| `caFingerprint` | `string` - If configured, verify that the fingerprint of the CA certificate that has signed the certificate of the server matches the supplied fingerprint. Only accepts SHA256 digest fingerprints.
208
+
_Default:_`null` |
209
+
| `maxResponseSize` | `number` - When configured, it verifies that the uncompressed 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*STRING_LENGTH
210
+
\_Default:*`null` |
211
+
| `maxCompressedResponseSize` | `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*LENGTH
Copy file name to clipboardExpand all lines: src/client.ts
-7Lines changed: 0 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -64,13 +64,6 @@ export interface NodeOptions {
64
64
ssl?: TlsConnectionOptions
65
65
/** @property headers Custom HTTP headers that should be sent with each request */
66
66
headers?: Record<string,any>
67
-
/** @property roles Common Elasticsearch roles that can be assigned to this node. Can be helpful when writing custom nodeFilter or nodeSelector functions. */
0 commit comments