Skip to content

Commit 222183d

Browse files
committed
[DOCS] Adds Configuration section to the client docs.
1 parent 394ba93 commit 222183d

File tree

3 files changed

+254
-4
lines changed

3 files changed

+254
-4
lines changed

docs/configuration.asciidoc

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
[[configuration]]
2+
== Configuration
3+
4+
Connecting to {es} with the client is easy, but it's possible that you'd like to
5+
change the default connection behaviour. There are a number of configuration
6+
options available on `ConnectionSettings` that can be used to control how the
7+
client interact with {es}.
8+
9+
=== Options on ConnectionConfiguration
10+
11+
The following is a list of available connection configuration options on
12+
`ConnectionConfiguration`:
13+
14+
`Authentication`::
15+
16+
An implementation of `IAuthenticationHeader` describing what http header to use
17+
to authenticate with the product.
18+
+
19+
`BasicAuthentication` for basic authentication
20+
+
21+
`ApiKey` for simple secret token
22+
+
23+
`Base64ApiKey` for Elastic Cloud style encoded api keys
24+
25+
`ClientCertificate`::
26+
27+
Use the following certificates to authenticate all HTTP requests. You can also
28+
set them on individual request using `ClientCertificates`.
29+
30+
`ClientCertificates`::
31+
32+
Use the following certificates to authenticate all HTTP requests. You can also
33+
set them on individual request using `ClientCertificates`.
34+
35+
`ConnectionLimit`::
36+
37+
Limits the number of concurrent connections that can be opened to an endpoint.
38+
Defaults to 80 (see `DefaultConnectionLimit`).
39+
+
40+
For Desktop CLR, this setting applies to the `DefaultConnectionLimit` property
41+
on the `ServicePointManager` object when creating `ServicePoint` objects,
42+
affecting the default `IConnection` implementation.
43+
+
44+
For Core CLR, this setting applies to the `MaxConnectionsPerServer` property on
45+
the `HttpClientHandler` instances used by the `HttpClient` inside the default
46+
`IConnection` implementation.
47+
48+
`DeadTimeout`::
49+
50+
The time to put dead nodes out of rotation (this will be multiplied by the
51+
number of times they've been dead).
52+
53+
`DisableAutomaticProxyDetection`::
54+
55+
Disabled proxy detection on the webrequest, in some cases this may speed up the
56+
first connection your appdomain makes, in other cases it will actually increase
57+
the time for the first connection. No silver bullet! Use with care!
58+
59+
`DisableDirectStreaming`::
60+
61+
When set to true will disable (de)serializing directly to the request and
62+
response stream and return a byte[] copy of the raw request and response.
63+
Defaults to false.
64+
65+
`DisablePing`::
66+
67+
This signals that we do not want to send initial pings to unknown/previously
68+
dead nodes and just send the call straightaway.
69+
70+
`DnsRefreshTimeout`::
71+
72+
DnsRefreshTimeout for the connections. Defaults to 5 minutes.
73+
74+
`EnableDebugMode`::
75+
76+
Turns on settings that aid in debugging like `DisableDirectStreaming()` and
77+
`PrettyJson()` so that the original request and response JSON can be inspected.
78+
It also always asks the server for the full stack trace on errors.
79+
80+
`EnableHttpCompression`::
81+
82+
Enable gzip compressed requests and responses.
83+
84+
`EnableHttpPipelining`::
85+
86+
Whether HTTP pipelining is enabled. The default is `true`.
87+
88+
`EnableTcpKeepAlive`::
89+
90+
Sets the keep-alive option on a TCP connection.
91+
+
92+
For Desktop CLR, sets `ServicePointManager`.`SetTcpKeepAlive`.
93+
94+
`EnableTcpStats`::
95+
96+
Enable statistics about TCP connections to be collected when making a request.
97+
98+
`GlobalHeaders`::
99+
100+
Try to send these headers for every request.
101+
102+
`GlobalQueryStringParameters`::
103+
104+
Append these query string parameters automatically to every request.
105+
106+
`MaxDeadTimeout`::
107+
108+
The maximum amount of time a node is allowed to marked dead.
109+
110+
`MaximumRetries`::
111+
112+
When a retryable exception occurs or status code is returned this controls the
113+
maximum amount of times we should retry the call to {es}.
114+
115+
`MaxRetryTimeout`::
116+
117+
Limits the total runtime including retries separately from `RequestTimeout`.
118+
When not specified defaults to `RequestTimeout` which itself defaults to 60
119+
seconds.
120+
121+
`MemoryStreamFactory`::
122+
123+
Provides a memory stream factory.
124+
125+
`NodePredicate`::
126+
127+
Register a predicate to select which nodes that you want to execute API calls
128+
on. Note that sniffing requests omit this predicate and always execute on all
129+
nodes. When using an `IConnectionPool` implementation that supports reseeding of
130+
nodes, this will default to omitting master only node from regular API calls.
131+
When using static or single node connection pooling it is assumed the list of
132+
node you instantiate the client with should be taken verbatim.
133+
134+
`OnRequestCompleted`::
135+
136+
Allows you to register a callback every time a an API call is returned.
137+
138+
`OnRequestDataCreated`::
139+
140+
An action to run when the `RequestData` for a request has been created.
141+
142+
`PingTimeout`::
143+
144+
The timeout in milliseconds to use for ping requests, which are issued to
145+
determine whether a node is alive.
146+
147+
`PrettyJson`::
148+
149+
Provide hints to serializer and products to produce pretty, non minified json.
150+
+
151+
Note: this is not a guarantee you will always get prettified json.
152+
153+
`Proxy`::
154+
155+
If your connection has to go through proxy, use this method to specify the
156+
proxy url.
157+
158+
`RequestTimeout`::
159+
160+
The timeout in milliseconds for each request to {es}.
161+
162+
`ServerCertificateValidationCallback`::
163+
164+
Register a `ServerCertificateValidationCallback` per request.
165+
166+
`SkipDeserializationForStatusCodes`::
167+
168+
Configure the client to skip deserialization of certain status codes, for
169+
example, you run {es} behind a proxy that returns an unexpected json format.
170+
171+
`SniffLifeSpan`::
172+
173+
Force a new sniff for the cluster when the cluster state information is older
174+
than the specified timespan.
175+
176+
`SniffOnConnectionFault`::
177+
178+
Force a new sniff for the cluster state every time a connection dies.
179+
180+
`SniffOnStartup`::
181+
182+
Sniff the cluster state immediately on startup.
183+
184+
`ThrowExceptions`::
185+
186+
Instead of following a c/go like error checking on response. `IsValid` do throw
187+
an exception (except when `SuccessOrKnownError` is false) on the client when a
188+
call resulted in an exception on either the client or the {es} server.
189+
+
190+
Reasons for such exceptions could be search parser errors, index missing
191+
exceptions, and so on.
192+
193+
`TransferEncodingChunked`::
194+
195+
Whether the request should be sent with chunked Transfer-Encoding.
196+
197+
`UserAgent`::
198+
199+
The user agent string to send with requests. Useful for debugging purposes to
200+
understand client and framework versions that initiate requests to {es}.
201+
202+
203+
==== Options on ConnectionSettings
204+
205+
The following is a list of available connection configuration options on
206+
`ConnectionSettings`:
207+
208+
`DefaultDisableIdInference`::
209+
210+
Disables automatic Id inference for given CLR types.
211+
+
212+
The client by default will use the value of a property named `Id` on a CLR type
213+
as the `_id` to send to {es}. Adding a type will disable this behaviour for that
214+
CLR type. If `Id` inference should be disabled for all CLR types, use
215+
`DefaultDisableIdInference`.
216+
217+
`DefaultFieldNameInferrer`::
218+
219+
Specifies how field names are inferred from CLR property names.
220+
+
221+
By default, the client camel cases property names. For example, CLR property
222+
`EmailAddress` will be inferred as "emailAddress" {es} document field name.
223+
224+
`DefaultIndex`::
225+
226+
The default index to use for a request when no index has been explicitly
227+
specified and no default indices are specified for the given CLR type specified
228+
for the request.
229+
230+
`DefaultMappingFor`::
231+
232+
Specify how the mapping is inferred for a given CLR type. The mapping can infer
233+
the index, id and relation name for a given CLR type, as well as control
234+
serialization behaviour for CLR properties.
235+
236+
==== ConnectionSettings with ElasticClient
237+
238+
Here's an example to demonstrate setting configuration options using the client.
239+
240+
[source,csharp]
241+
----
242+
var connectionSettings = new ConnectionSettings()
243+
.DefaultMappingFor<Project>(i => i
244+
.IndexName("my-projects")
245+
.IdProperty(p => p.Name)
246+
)
247+
.EnableDebugMode()
248+
.PrettyJson()
249+
.RequestTimeout(TimeSpan.FromMinutes(2));
250+
251+
var client = new ElasticClient(connectionSettings);
252+
----

docs/high-level.asciidoc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ include::{output-dir}/getting-started.asciidoc[]
5252
NEST uses sensible defaults for connecting to and interacting with an Elasticsearch cluster but provides numerous
5353
configuration options and components to change this behaviour
5454

55-
* <<configuration-options, Configuration options>>
56-
5755
* <<connection-pooling, Connection pools>>
5856

5957
* <<modifying-default-connection, Modifying the default connection>>
@@ -62,8 +60,6 @@ configuration options and components to change this behaviour
6260

6361
* <<function-as-a-service-environments, Using the Client in a Function-as-a-Service Environment>>
6462

65-
include::client-concepts/connection/configuration-options.asciidoc[]
66-
6763
include::client-concepts/connection-pooling/building-blocks/connection-pooling.asciidoc[]
6864

6965
include::client-concepts/connection/modifying-default-connection.asciidoc[]

docs/index.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ include::install.asciidoc[]
1919

2020
include::connecting.asciidoc[]
2121

22+
include::configuration.asciidoc[]
23+
2224
include::breaking-changes.asciidoc[]
2325

2426
include::conventions.asciidoc[]

0 commit comments

Comments
 (0)