2017-10-12 08:18:44 -04:00
|
|
|
[role="xpack"]
|
|
|
|
[[setup-xpack-client]]
|
|
|
|
== Configuring {xpack} Java Clients
|
|
|
|
|
2017-10-12 09:27:33 -04:00
|
|
|
If you want to use a Java {javaclient}/transport-client.html[transport client] with a
|
2017-10-12 08:18:44 -04:00
|
|
|
cluster where {xpack} is installed, then you must download and configure the
|
|
|
|
{xpack} transport client.
|
|
|
|
|
|
|
|
WARNING: The `TransportClient` is aimed to be replaced by the Java High Level REST
|
|
|
|
Client, which executes HTTP requests instead of serialized Java requests. The
|
2017-10-12 09:27:33 -04:00
|
|
|
`TransportClient` will be deprecated in upcoming versions of {es}.
|
2017-10-12 08:18:44 -04:00
|
|
|
|
|
|
|
. Add the {xpack} transport JAR file to your *CLASSPATH*. You can download the {xpack}
|
|
|
|
distribution and extract the JAR file manually or you can get it from the
|
|
|
|
https://artifacts.elastic.co/maven/org/elasticsearch/client/x-pack-transport/{version}/x-pack-transport-{version}.jar[Elasticsearc Maven repository].
|
|
|
|
As with any dependency, you will also need its transitive dependencies. Refer to the
|
|
|
|
https://artifacts.elastic.co/maven/org/elasticsearch/client/x-pack-transport/{version}/x-pack-transport-{version}.pom[X-Pack POM file
|
|
|
|
for your version] when downloading for offline usage.
|
|
|
|
|
|
|
|
. If you are using Maven, you need to add the {xpack} JAR file as a dependency in
|
|
|
|
your project's `pom.xml` file:
|
|
|
|
+
|
|
|
|
--
|
|
|
|
[source,xml]
|
|
|
|
--------------------------------------------------------------
|
|
|
|
<project ...>
|
|
|
|
<repositories>
|
|
|
|
<!-- add the elasticsearch repo -->
|
|
|
|
<repository>
|
|
|
|
<id>elasticsearch-releases</id>
|
|
|
|
<url>https://artifacts.elastic.co/maven</url>
|
|
|
|
<releases>
|
|
|
|
<enabled>true</enabled>
|
|
|
|
</releases>
|
|
|
|
<snapshots>
|
|
|
|
<enabled>false</enabled>
|
|
|
|
</snapshots>
|
|
|
|
</repository>
|
|
|
|
...
|
|
|
|
</repositories>
|
|
|
|
...
|
|
|
|
|
|
|
|
<dependencies>
|
|
|
|
<!-- add the x-pack jar as a dependency -->
|
|
|
|
<dependency>
|
|
|
|
<groupId>org.elasticsearch.client</groupId>
|
|
|
|
<artifactId>x-pack-transport</artifactId>
|
|
|
|
<version>{version}</version>
|
|
|
|
</dependency>
|
|
|
|
...
|
|
|
|
</dependencies>
|
|
|
|
...
|
|
|
|
|
|
|
|
</project>
|
|
|
|
--------------------------------------------------------------
|
|
|
|
--
|
|
|
|
|
|
|
|
. If you are using Gradle, you need to add the {xpack} JAR file as a dependency in
|
|
|
|
your `build.gradle` file:
|
|
|
|
+
|
|
|
|
--
|
|
|
|
[source,groovy]
|
|
|
|
--------------------------------------------------------------
|
|
|
|
repositories {
|
|
|
|
/* ... Any other repositories ... */
|
|
|
|
|
|
|
|
// Add the Elasticsearch Maven Repository
|
|
|
|
maven {
|
|
|
|
url "https://artifacts.elastic.co/maven"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
compile "org.elasticsearch.client:x-pack-transport:{version}"
|
|
|
|
|
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
--------------------------------------------------------------
|
|
|
|
--
|
|
|
|
|
|
|
|
. If you are using a repository manager such as https://www.sonatype.com/nexus-repository-oss[Nexus OSS] within your
|
|
|
|
company, you need to add the repository as per the following screenshot:
|
|
|
|
+
|
|
|
|
--
|
|
|
|
image::security/images/nexus.png["Adding the Elastic repo in Nexus",link="images/nexus.png"]
|
|
|
|
|
|
|
|
Then in your project's `pom.xml` if using maven, add the following repositories and dependencies definitions:
|
|
|
|
|
|
|
|
[source,xml]
|
|
|
|
--------------------------------------------------------------
|
|
|
|
<dependencies>
|
|
|
|
<dependency>
|
|
|
|
<groupId>org.elasticsearch.client</groupId>
|
|
|
|
<artifactId>x-pack-transport</artifactId>
|
|
|
|
<version>{version}</version>
|
|
|
|
</dependency>
|
|
|
|
</dependencies>
|
|
|
|
|
|
|
|
<repositories>
|
|
|
|
<repository>
|
|
|
|
<id>local-nexus</id>
|
|
|
|
<name>Elastic Local Nexus</name>
|
|
|
|
<url>http://0.0.0.0:8081/repository/elasticsearch/</url>
|
|
|
|
<releases>
|
|
|
|
<enabled>true</enabled>
|
|
|
|
</releases>
|
|
|
|
<snapshots>
|
|
|
|
<enabled>false</enabled>
|
|
|
|
</snapshots>
|
|
|
|
</repository>
|
|
|
|
</repositories>
|
|
|
|
--------------------------------------------------------------
|
|
|
|
--
|
|
|
|
|
|
|
|
. If you are using {security}, there are more configuration steps. See
|
|
|
|
{xpack-ref}/java-clients.html[Java Client and Security].
|