Skip to content

Commit 37ae9d0

Browse files
add migrated files
1 parent eb40f18 commit 37ae9d0

27 files changed

+2480
-0
lines changed

docs/docset.yml

Lines changed: 487 additions & 0 deletions
Large diffs are not rendered by default.

docs/images/create-api-key.png

78.7 KB
Loading

docs/images/es-endpoint.jpg

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

docs/reference/aggregations.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
---
2+
mapped_pages:
3+
- https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/aggregations.html
4+
---
5+
6+
# Aggregation examples [aggregations]
7+
8+
This page demonstrates how to use aggregations.
9+
10+
11+
## Top-level aggreggation [_top_level_aggreggation]
12+
13+
14+
### Fluent API [_fluent_api]
15+
16+
```csharp
17+
var response = await client
18+
.SearchAsync<Person>(search => search
19+
.Index("persons")
20+
.Query(query => query
21+
.MatchAll(_ => {})
22+
)
23+
.Aggregations(aggregations => aggregations
24+
.Add("agg_name", aggregation => aggregation
25+
.Max(max => max
26+
.Field(x => x.Age)
27+
)
28+
)
29+
)
30+
.Size(10)
31+
);
32+
```
33+
34+
35+
### Object initializer API [_object_initializer_api]
36+
37+
```csharp
38+
var response = await client.SearchAsync<Person>(new SearchRequest("persons")
39+
{
40+
Query = Query.MatchAll(new MatchAllQuery()),
41+
Aggregations = new Dictionary<string, Aggregation>
42+
{
43+
{ "agg_name", Aggregation.Max(new MaxAggregation
44+
{
45+
Field = Infer.Field<Person>(x => x.Age)
46+
})}
47+
},
48+
Size = 10
49+
});
50+
```
51+
52+
53+
### Consume the response [_consume_the_response]
54+
55+
```csharp
56+
var max = response.Aggregations!.GetMax("agg_name")!;
57+
Console.WriteLine(max.Value);
58+
```
59+
60+
61+
## Sub-aggregation [_sub_aggregation]
62+
63+
64+
### Fluent API [_fluent_api_2]
65+
66+
```csharp
67+
var response = await client
68+
.SearchAsync<Person>(search => search
69+
.Index("persons")
70+
.Query(query => query
71+
.MatchAll(_ => {})
72+
)
73+
.Aggregations(aggregations => aggregations
74+
.Add("firstnames", aggregation => aggregation
75+
.Terms(terms => terms
76+
.Field(x => x.FirstName)
77+
)
78+
.Aggregations(aggregations => aggregations
79+
.Add("avg_age", aggregation => aggregation
80+
.Max(avg => avg
81+
.Field(x => x.Age)
82+
)
83+
)
84+
)
85+
)
86+
)
87+
.Size(10)
88+
);
89+
```
90+
91+
92+
### Object initializer API [_object_initializer_api_2]
93+
94+
```csharp
95+
var topLevelAggregation = Aggregation.Terms(new TermsAggregation
96+
{
97+
Field = Infer.Field<Person>(x => x.FirstName)
98+
});
99+
100+
topLevelAggregation.Aggregations = new Dictionary<string, Aggregation>
101+
{
102+
{ "avg_age", new MaxAggregation
103+
{
104+
Field = Infer.Field<Person>(x => x.Age)
105+
}}
106+
};
107+
108+
var response = await client.SearchAsync<Person>(new SearchRequest("persons")
109+
{
110+
Query = Query.MatchAll(new MatchAllQuery()),
111+
Aggregations = new Dictionary<string, Aggregation>
112+
{
113+
{ "firstnames", topLevelAggregation}
114+
},
115+
Size = 10
116+
});
117+
```
118+
119+
120+
### Consume the response [_consume_the_response_2]
121+
122+
```csharp
123+
var firstnames = response.Aggregations!.GetStringTerms("firstnames")!;
124+
foreach (var bucket in firstnames.Buckets)
125+
{
126+
var avg = bucket.Aggregations.GetAverage("avg_age")!;
127+
Console.WriteLine($"The average age for persons named '{bucket.Key}' is {avg}");
128+
}
129+
```
130+

docs/reference/client-concepts.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
mapped_pages:
3+
- https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/client-concepts.html
4+
---
5+
6+
# Client concepts [client-concepts]
7+
8+
The .NET client for {{es}} maps closely to the original {{es}} API. All
9+
requests and responses are exposed through types, making it ideal for getting up and running quickly.

docs/reference/configuration.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
mapped_pages:
3+
- https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/configuration.html
4+
---
5+
6+
# Configuration [configuration]
7+
8+
Connecting to {{es}} with the client is easy, but it’s possible that you’d like to change the default connection behaviour. There are a number of configuration options available on `ElasticsearchClientSettings` that can be used to control how the client interact with {{es}}.
9+
10+

0 commit comments

Comments
 (0)