Skip to content

Commit af27f24

Browse files
[DOCS] Add usage section and recommendations (#6973) (#6980)
* Add usage sub-section and move examples * Reorder items * Stub out sections and fix headings * Add additional dependency * Reorder includes * Update to ref-current for docs links * Add initial recommendations * Update recommendations * Attempt to fix generated URLs * Update includes * Fix connecting link Co-authored-by: Steve Gordon <[email protected]>
1 parent 3bd855a commit af27f24

File tree

5 files changed

+69
-18
lines changed

5 files changed

+69
-18
lines changed

docs/connecting.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ SHA256 Fingerprint=<FINGERPRINT>
112112
----
113113

114114
Visit the
115-
{ref-current}/configuring-stack-security.html[Connect clients to {es}] documentation for more information.
115+
{ref}/configuring-stack-security.html[Start the Elastic Stack with security enabled automatically]
116+
documentation for more information.
116117

117118
The following snippet shows you how to create a client instance that connects to
118119
your {es} cluster via a single node, using the CA fingerprint:

docs/index.asciidoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
:title-separator: |
2-
31
[[elasticsearch-net-reference]]
42
= Elasticsearch .NET Client
53

6-
:net-client: Elasticsearch .NET Client
7-
:ref-current: {ref}
8-
9-
4+
include::{asciidoc-dir}/../../shared/versions/stack/{source_branch}.asciidoc[]
105
include::{asciidoc-dir}/../../shared/attributes.asciidoc[]
116

7+
:net-client: Elasticsearch .NET Client
8+
129
include::intro.asciidoc[]
1310

1411
include::install.asciidoc[]
@@ -17,7 +14,7 @@ include::connecting.asciidoc[]
1714

1815
include::configuration.asciidoc[]
1916

20-
include::examples.asciidoc[]
17+
include::usage/index.asciidoc[]
2118

2219
include::troubleshooting.asciidoc[]
2320

docs/examples.asciidoc renamed to docs/usage/examples.asciidoc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[[examples]]
2-
== Examples
2+
=== CRUD usage examples
33

44
This page helps you to understand how to perform various basic {es} CRUD
5-
operations using the .NET client. It demonstrates how to create a document by
6-
indexing an object into {es}, read a document back, retrieving it by ID or
7-
performing a search, update one of the fields in a document and delete a
8-
specific document.
5+
(create, read, update, delete) operations using the .NET client. It demonstrates
6+
how to create a document by indexing an object into {es}, read a document back,
7+
retrieving it by ID or performing a search, update one of the fields in a
8+
document and delete a specific document.
99

1010
These examples assume you have an instance of the `ElasticsearchClient`
1111
accessible via a local variable named `client` and several using directives in
@@ -45,7 +45,7 @@ using the ID specified by the value of this property.
4545

4646
[discrete]
4747
[[indexing-net]]
48-
=== Indexing a document
48+
==== Indexing a document
4949

5050
Documents can be indexed by creating an instance representing a tweet and
5151
indexing it via the client. In these examples, we will work with an index named
@@ -77,7 +77,7 @@ operation succeeded.
7777

7878
[discrete]
7979
[[getting-net]]
80-
=== Getting a document
80+
==== Getting a document
8181

8282
[source,csharp]
8383
----
@@ -91,7 +91,7 @@ accessible on the response via the `Source` property.
9191

9292
[discrete]
9393
[[searching-net]]
94-
=== Searching for documents
94+
==== Searching for documents
9595

9696
The client exposes a fluent interface and a powerful query DSL for searching.
9797

@@ -146,7 +146,7 @@ search operation.
146146

147147
[discrete]
148148
[[updating-net]]
149-
=== Updating documents
149+
==== Updating documents
150150

151151
Documents can be updated in several ways, including by providing a complete
152152
replacement for an existing document ID.
@@ -169,7 +169,7 @@ if (response.IsValid)
169169

170170
[discrete]
171171
[[deleting-net]]
172-
=== Deleting documents
172+
==== Deleting documents
173173

174174
Documents can be deleted by providing the ID of the document to remove.
175175

docs/usage/index.asciidoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[[usage]]
2+
== Using the .NET Client
3+
4+
The sections below provide tutorials on the most frequently used and some less obvious features of {es}.
5+
6+
For a full reference, see the {ref}/[Elasticsearch documentation] and in particular the {ref}/rest-apis.html[REST APIs] section. The {net-client} follows closely the JSON structures described there.
7+
8+
If you're new to {es}, make sure also to read {ref}/getting-started.html[Elasticsearch's quick start] that provides a good introduction.
9+
10+
* <<recommendations, Usage recommendations>>
11+
* <<examples, CRUD usage examples>>
12+
13+
NOTE: This is still a work in progress, more sections will be added in the near future.
14+
15+
include::recommendations.asciidoc[]
16+
include::examples.asciidoc[]

docs/usage/recommendations.asciidoc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[[recommendations]]
2+
=== Usage recommendations
3+
4+
To achieve the most efficient use of the {net-client}, we recommend following
5+
the guidance defined in this article.
6+
7+
[discrete]
8+
==== Reuse the same client instance
9+
10+
When working with the {net-client} we recommend that consumers reuse a single
11+
instance of `ElasticsearchClient` for the entire lifetime of the application.
12+
When reusing the same instance:
13+
14+
- initialization overhead is limited to the first usage.
15+
- resources such as TCP connections can be pooled and reused to improve
16+
efficiency.
17+
- serialization overhead is reduced, improving performance.
18+
19+
The `ElasticsearchClient` type is thread-safe and can be shared and reused
20+
across multiple threads in consuming applications. Client reuse can be achieved
21+
by creating a singleton static instance or by registering the type with a
22+
singleton lifetime when using dependency injection containers.
23+
24+
[discrete]
25+
==== Prefer asynchronous methods
26+
27+
The {net-client} exposes synchronous and asynchronous methods on the
28+
`ElasticsearchClient`. We recommend always preferring the asynchronous methods,
29+
which have the `Async` suffix. Using the {net-client} requires sending HTTP
30+
requests to {es} servers. Access to {es} is sometimes slow or delayed, and some
31+
complex queries may take several seconds to return. If such operations are
32+
blocked by calling the synchronous methods, the thread must wait until the HTTP
33+
request is complete. In high-load scenarios, this can cause significant thread
34+
usage, potentially affecting the throughput and performance of consuming
35+
applications. By preferring the asynchronous methods, application threads can
36+
continue with other work that doesn't depend on the web resource until the
37+
potentially blocking task completes.

0 commit comments

Comments
 (0)