Skip to content

Commit db221c2

Browse files
committed
Add rest5_client docs
1 parent 7e7d4fd commit db221c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1024
-111
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:::{note}
2+
This is the legacy RestClient. Please migrate to [Rest5Client](/reference/transport/rest5-client/index.md), a drop-in replacement with an up-to-date http library.
3+
:::

docs/reference/api-conventions/blocking-async.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Both flavors can be used at the same time depending on your needs, sharing the s
1212
% :::{include-code} src={{doc-tests-src}}/api_conventions/ApiConventionsTest.java tag=blocking-and-async
1313
```java
1414
// Synchronous blocking client
15-
ElasticsearchClient client = new ElasticsearchClient(transport);
15+
ElasticsearchClient esClient = new ElasticsearchClient(transport);
1616

17-
if (client.exists(b -> b.index("products").id("foo")).value()) {
17+
if (esClient.exists(b -> b.index("products").id("foo")).value()) {
1818
logger.info("product exists");
1919
}
2020

docs/reference/api-conventions/building-objects.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ All data types in the Java API Client are immutable. Object creation uses the [b
1212

1313
% :::{include-code} src={{doc-tests-src}}/api_conventions/ApiConventionsTest.java tag=builders
1414
```java
15-
ElasticsearchClient client = createClient();
16-
CreateIndexResponse createResponse = client.indices().create(
15+
ElasticsearchClient esClient = createClient();
16+
CreateIndexResponse createResponse = esClient.indices().create(
1717
new CreateIndexRequest.Builder()
1818
.index("my-index")
1919
.aliases("foo",
@@ -32,8 +32,8 @@ Although this works nicely, having to instantiate builder classes and call the `
3232

3333
% :::{include-code} src={{doc-tests-src}}/api_conventions/ApiConventionsTest.java tag=builder-lambdas
3434
```java
35-
ElasticsearchClient client = createClient();
36-
CreateIndexResponse createResponse = client.indices()
35+
ElasticsearchClient esClient = createClient();
36+
CreateIndexResponse createResponse = esClient.indices()
3737
.create(createIndexBuilder -> createIndexBuilder
3838
.index("my-index")
3939
.aliases("foo", aliasBuilder -> aliasBuilder
@@ -48,8 +48,8 @@ Note in the above example that builder variables are only used to start a chain
4848

4949
% :::{include-code} src={{doc-tests-src}}/api_conventions/ApiConventionsTest.java tag=builder-lambdas-short
5050
```java
51-
ElasticsearchClient client = createClient();
52-
CreateIndexResponse createResponse = client.indices()
51+
ElasticsearchClient esClient = createClient();
52+
CreateIndexResponse createResponse = esClient.indices()
5353
.create(c -> c
5454
.index("my-index")
5555
.aliases("foo", a -> a
@@ -64,8 +64,8 @@ This example also highlights a useful naming convention for builder parameters i
6464

6565
% :::{include-code} src={{doc-tests-src}}/api_conventions/ApiConventionsTest.java tag=builder-intervals
6666
```java
67-
ElasticsearchClient client = createClient();
68-
SearchResponse<SomeApplicationData> results = client
67+
ElasticsearchClient esClient = createClient();
68+
SearchResponse<SomeApplicationData> results = esClient
6969
.search(b0 -> b0
7070
.query(b1 -> b1
7171
.intervals(b2 -> b2

docs/reference/api-conventions/loading-json.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ CreateIndexRequest req = CreateIndexRequest.of(b -> b
4141
.withJson(input) // <2>
4242
);
4343

44-
boolean created = client.indices().create(req).acknowledged();
44+
boolean created = esClient.indices().create(req).acknowledged();
4545
```
4646

4747
1. open an input stream for the JSON resource file.
@@ -64,7 +64,7 @@ req = IndexRequest.of(b -> b
6464
.withJson(file)
6565
);
6666

67-
client.index(req);
67+
esClient.index(req);
6868
```
6969

7070
1. when calling `withJson()` on data structures that have generic type parameters, these generic types will be considered to be `JsonData`.
@@ -102,7 +102,7 @@ SearchRequest aggRequest = SearchRequest.of(b -> b
102102
.size(0)
103103
);
104104

105-
Map<String, Aggregate> aggs = client
105+
Map<String, Aggregate> aggs = esClient
106106
.search(aggRequest, Void.class) // <3>
107107
.aggregations();
108108
```
@@ -157,7 +157,7 @@ SearchRequest aggRequest = SearchRequest.of(b -> b
157157
.ignoreUnavailable(true) // <5>
158158
);
159159

160-
Map<String, Aggregate> aggs = client
160+
Map<String, Aggregate> aggs = esClient
161161
.search(aggRequest, Void.class)
162162
.aggregations();
163163
```

docs/reference/setup/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies {
2626

2727
In the `pom.xml` of your project, add the following repository definition and dependencies:
2828

29-
```xml
29+
```xml subs=true
3030
<project>
3131
<dependencies>
3232

docs/reference/toc.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,30 @@ toc:
3939
children:
4040
- file: index.md
4141

42+
- folder: rest5-client
43+
children:
44+
- file: index.md
45+
- folder: usage
46+
children:
47+
- file: index.md
48+
- file: initialization.md
49+
- file: requests.md
50+
- file: responses.md
51+
- file: logging.md
52+
- folder: config
53+
children:
54+
- file: index.md
55+
- file: timeouts.md
56+
- file: number_of_threads.md
57+
- file: basic_authentication.md
58+
- file: other_authentication_methods.md
59+
- file: encrypted_communication.md
60+
- file: others.md
61+
- file: node_selector.md
62+
- folder: sniffer
63+
children:
64+
- file: index.md
65+
4266
- folder: rest-client
4367
children:
4468
- file: index.md

docs/reference/transport/rest-client/config/basic_authentication.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ mapped_pages:
55

66
# Basic authentication [_basic_authentication]
77

8+
:::{include} /reference/_snippets/legacy-rest-client.md
9+
:::
10+
811
Configuring basic authentication can be done by providing an `HttpClientConfigCallback` while building the `RestClient` through its builder. The interface has one method that receives an instance of [`org.apache.http.impl.nio.client.HttpAsyncClientBuilder`](https://hc.apache.org/httpcomponents-asyncclient-4.1.x/current/httpasyncclient/apidocs/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.html) as an argument and has the same return type. The http client builder can be modified and then returned. In the following example we set a default credentials provider that requires basic authentication.
912

1013
```java

docs/reference/transport/rest-client/config/encrypted_communication.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ mapped_pages:
55

66
# Encrypted communication [_encrypted_communication]
77

8+
:::{include} /reference/_snippets/legacy-rest-client.md
9+
:::
10+
811
Encrypted communication using TLS can also be configured through the `HttpClientConfigCallback`. The [`org.apache.http.impl.nio.client.HttpAsyncClientBuilder`](https://hc.apache.org/httpcomponents-asyncclient-4.1.x/current/httpasyncclient/apidocs/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.html) received as an argument exposes multiple methods to configure encrypted communication: `setSSLContext`, `setSSLSessionStrategy` and `setConnectionManager`, in order of precedence from the least important.
912

1013
When accessing an Elasticsearch cluster that is setup for TLS on the HTTP layer, the client needs to trust the certificate that Elasticsearch is using. The following is an example of setting up the client to trust the CA that has signed the certificate that Elasticsearch is using, when that CA certificate is available in a PKCS#12 keystore:

docs/reference/transport/rest-client/config/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ mapped_pages:
55

66
# Common configuration [java-rest-low-config]
77

8+
:::{include} /reference/_snippets/legacy-rest-client.md
9+
:::
10+
811
As explained in [Initialization](../usage/initialization.md), the `RestClientBuilder` supports providing both a `RequestConfigCallback` and an `HttpClientConfigCallback` which allow for any customization that the Apache Async Http Client exposes. Those callbacks make it possible to modify some specific behaviour of the client without overriding every other default configuration that the `RestClient` is initialized with. This section describes some common scenarios that require additional configuration for the low-level Java REST Client.
912

1013

docs/reference/transport/rest-client/config/node_selector.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ mapped_pages:
55

66
# Node selector [_node_selector]
77

8+
:::{include} /reference/_snippets/legacy-rest-client.md
9+
:::
10+
811
The client sends each request to one of the configured nodes in round-robin fashion. Nodes can optionally be filtered through a node selector that needs to be provided when initializing the client. This is useful when sniffing is enabled, in case no dedicated master nodes should be hit by HTTP requests. For each request the client will run the eventually configured node selector to filter the node candidates, then select the next one in the list out of the remaining ones.
912

1013
```java

0 commit comments

Comments
 (0)