|
@@ -1,6 +1,8 @@
|
|
|
-== Getting started
|
|
|
+[[java-rest-low-usage]]
|
|
|
+=== Getting started
|
|
|
|
|
|
-=== Maven Repository
|
|
|
+[[java-rest-low-usage-maven]]
|
|
|
+==== Maven Repository
|
|
|
|
|
|
The low-level Java REST client is hosted on
|
|
|
http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.elasticsearch.client%22[Maven
|
|
@@ -8,11 +10,12 @@ Central]. The minimum Java version required is `1.7`.
|
|
|
|
|
|
The low-level REST client is subject to the same release cycle as
|
|
|
elasticsearch. Replace the version with the desired client version, first
|
|
|
-released with `5.0.0-alpha4`. There is no relation between the client version
|
|
|
+released with `5.0.0-alpha4`. There is no relation between the client version
|
|
|
and the elasticsearch version that the client can communicate with. The
|
|
|
low-level REST client is compatible with all elasticsearch versions.
|
|
|
|
|
|
-==== Maven configuration
|
|
|
+[[java-rest-low-usage-maven-maven]]
|
|
|
+===== Maven configuration
|
|
|
|
|
|
Here is how you can configure the dependency using maven as a dependency manager.
|
|
|
Add the following to your `pom.xml` file:
|
|
@@ -26,7 +29,8 @@ Add the following to your `pom.xml` file:
|
|
|
</dependency>
|
|
|
--------------------------------------------------
|
|
|
|
|
|
-==== Gradle configuration
|
|
|
+[[java-rest-low-usage-maven-gradle]]
|
|
|
+===== Gradle configuration
|
|
|
|
|
|
Here is how you can configure the dependency using gradle as a dependency manager.
|
|
|
Add the following to your `build.gradle` file:
|
|
@@ -38,7 +42,8 @@ dependencies {
|
|
|
}
|
|
|
--------------------------------------------------
|
|
|
|
|
|
-=== Dependencies
|
|
|
+[[java-rest-low-usage-dependencies]]
|
|
|
+==== Dependencies
|
|
|
|
|
|
The low-level Java REST client internally uses the
|
|
|
http://hc.apache.org/httpcomponents-asyncclient-dev/[Apache Http Async Client]
|
|
@@ -53,7 +58,8 @@ http://hc.apache.org/httpcomponents-asyncclient-dev/[Apache Http Async Client]
|
|
|
- commons-logging:commons-logging
|
|
|
|
|
|
|
|
|
-=== Initialization
|
|
|
+[[java-rest-low-usage-initialization]]
|
|
|
+==== Initialization
|
|
|
|
|
|
A `RestClient` instance can be built through the corresponding
|
|
|
`RestClientBuilder` class, created via `RestClient#builder(HttpHost...)`
|
|
@@ -101,7 +107,8 @@ http://hc.apache.org/httpcomponents-asyncclient-dev/httpasyncclient/apidocs/org/
|
|
|
allows to set)
|
|
|
|
|
|
|
|
|
-=== Performing requests
|
|
|
+[[java-rest-low-usage-requests]]
|
|
|
+==== Performing requests
|
|
|
|
|
|
Once the `RestClient` has been created, requests can be sent by calling one of
|
|
|
the available `performRequest` or `performRequestAsync` method variants.
|
|
@@ -159,7 +166,8 @@ void performRequestAsync(String method, String endpoint,
|
|
|
Header... headers);
|
|
|
--------------------------------------------------
|
|
|
|
|
|
-==== Request Arguments
|
|
|
+[[java-rest-low-usage-requests-arguments]]
|
|
|
+===== Request Arguments
|
|
|
|
|
|
The following are the arguments accepted by the different methods:
|
|
|
|
|
@@ -179,7 +187,8 @@ http://hc.apache.org/httpcomponents-core-ga/httpcore-nio/apidocs/org/apache/http
|
|
|
request success or failure
|
|
|
`headers`:: optional request headers
|
|
|
|
|
|
-=== Reading responses
|
|
|
+[[java-rest-low-usage-responses]]
|
|
|
+==== Reading responses
|
|
|
|
|
|
The `Response` object, either returned by the synchronous `performRequest` methods or
|
|
|
received as an argument in `ResponseListener#onSuccess(Response)`, wraps the
|
|
@@ -216,7 +225,8 @@ case the response body will not contain an error but rather the usual get api
|
|
|
response, just without the document as it was not found.
|
|
|
|
|
|
|
|
|
-=== Example requests
|
|
|
+[[java-rest-low-usage-example]]
|
|
|
+==== Example requests
|
|
|
|
|
|
Here are a couple of examples:
|
|
|
|
|
@@ -293,7 +303,8 @@ latch.await();
|
|
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
-=== Logging
|
|
|
+[[java-rest-low-usage-logging]]
|
|
|
+==== Logging
|
|
|
|
|
|
The Java REST client uses the same logging library that the Apache Async Http
|
|
|
Client uses: https://commons.apache.org/proper/commons-logging/[Apache Commons Logging],
|