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
Copy file name to clipboardExpand all lines: docs/configuration.asciidoc
+51-20Lines changed: 51 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,9 @@
1
1
[[client-configuration]]
2
2
== Client configuration
3
3
4
-
The client is designed to be easily configured as you see fit for your needs, following you can see all the possible basic options that you can use to configure it.
4
+
The client is designed to be easily configured for your needs. In the following
5
+
section, you can see the possible basic options that you can use to configure
6
+
it.
5
7
6
8
[source,js]
7
9
----
@@ -15,7 +17,9 @@ const client = new Client({
15
17
})
16
18
----
17
19
20
+
18
21
=== Basic options
22
+
19
23
[cols=2*]
20
24
|===
21
25
|`node` or `nodes`
@@ -25,7 +29,7 @@ It can be a single string or an array of strings:
25
29
----
26
30
node: 'http://localhost:9200'
27
31
----
28
-
Or it can be an object (or an array of objects) that represents the node
32
+
Or it can be an object (or an array of objects) that represents the node:
29
33
[source,js]
30
34
----
31
35
node: {
@@ -44,8 +48,10 @@ node: {
44
48
----
45
49
46
50
|`auth`
47
-
a|Your authentication data. You can use both Basic authentication and https://www.elastic.co/guide/en/elasticsearch/reference/7.x/security-api-create-api-key.html[ApiKey]. +
48
-
See https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/auth-reference.html[Authentication] for more details. +
51
+
a|Your authentication data. You can use both basic authentication and
52
+
{ref}/security-api-create-api-key.html[ApiKey]. +
53
+
See https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/auth-reference.html[Authentication]
a|`http.AgentOptions, function` - http agent https://nodejs.org/api/http.html#http_new_agent_options[options], or a function that returns an actual http agent instance. +
or a function that returns an actual http agent instance. +
116
123
_Default:_ `null`
117
124
[source,js]
118
125
----
@@ -157,7 +164,8 @@ function nodeSelector (connections) {
157
164
----
158
165
159
166
|`generateRequestId`
160
-
a|`function` - function to generate the request id for every request, it takes two parameters, the request parameters and options. +
167
+
a|`function` - function to generate the request id for every request, it takes
168
+
two parameters, the request parameters and options. +
161
169
By default it generates an incremental integer for every request. +
162
170
_Custom function example:_
163
171
[source,js]
@@ -178,7 +186,9 @@ _Default:_ `elasticsearch-js`
178
186
_Default:_ `{}`
179
187
180
188
|`cloud`
181
-
a|`object` - Custom configuration for connecting to https://cloud.elastic.co[Elastic Cloud]. See https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/auth-reference.html[Authentication] for more details. +
189
+
a|`object` - Custom configuration for connecting to
190
+
https://cloud.elastic.co[Elastic Cloud]. See https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/auth-reference.html[Authentication]
191
+
for more details. +
182
192
_Default:_ `null` +
183
193
_Cloud configuration example:_
184
194
[source,js]
@@ -196,17 +206,23 @@ const client = new Client({
196
206
197
207
|===
198
208
209
+
199
210
=== Advanced configuration
200
-
If you need to customize the client behavior heavily, you are in the right place! +
201
-
The client allows you to customize the following internals:
211
+
212
+
If you need to customize the client behavior heavily, you are in the right
213
+
place! The client allows you to customize the following internals:
202
214
203
215
* `Transport` class
204
216
* `ConnectionPool` class
205
217
* `Connection` class
206
218
* `Serializer` class
207
219
220
+
208
221
=== `Transport`
209
-
This class is responsible to perform the request to Elasticsearch and handling errors, it also handle the sniffing.
222
+
223
+
This class is responsible for performing the request to {es} and handling
224
+
errors, it also handles the sniffing.
225
+
210
226
[source,js]
211
227
----
212
228
const { Client, Transport } = require('@elastic/elasticsearch')
@@ -222,7 +238,9 @@ const client = new Client({
222
238
})
223
239
----
224
240
225
-
Sometimes you just need to inject a little snippet of your code and then continue to use the usual client code, in such case, you should call `super.method`.
241
+
Sometimes you need to inject a small snippet of your code and then continue to
242
+
use the usual client code. In such cases, call `super.method`:
243
+
226
244
[source,js]
227
245
----
228
246
class MyTransport extends Transport {
@@ -233,9 +251,13 @@ class MyTransport extends Transport {
233
251
}
234
252
----
235
253
254
+
236
255
=== `ConnectionPool`
237
-
This class is responsible for keeping in memory all the Elasticsearch Connection that we are using, there is a single Connection for every node. +
238
-
Moreover, the connection pool will handle the resurrection strategies and the updates of the pool.
256
+
257
+
This class is responsible for keeping in memory all the {es} Connection that we
258
+
are using. There is a single Connection for every node. The connection pool
259
+
handles the resurrection strategies and the updates of the pool.
This class represents a single Node, it holds every information we have on the node, such as roles, id, URL, custom headers and so on. The actual HTTP request is performed here, this means that if you want to swap the default HTTP client (Node.js core), you should override this class `request` method.
279
+
280
+
This class represents a single node, it holds every information we have on the
281
+
node, such as roles, id, URL, custom headers and so on. The actual HTTP request
282
+
is performed here, this means that if you want to swap the default HTTP client
283
+
(Node.js core), you should override the `request` method of this class.
0 commit comments