ElasticSearch: Low Level Rest Client Connection

This entry is part 1 of 3 in the series ElasticSearch Low Level Rest Client
(Last Updated On: )

In this tutorial I will show you how to use the ElasticSearch low level rest client.

First you will need to add the low level rest to the pom.

  1. <properties>
  2. <elasticSearch.version>6.2.4</elasticSearch.version>
  3. </properties>
  4.  
  5. <dependency>
  6. <groupId>org.elasticsearch.client</groupId>
  7. <artifactId>elasticsearch-rest-client</artifactId>
  8. <version>${elasticSearch.version}</version>
  9. </dependency>

Next you will need to specify the imports.

  1. import org.apache.http.HttpHost;
  2. import org.elasticsearch.client.Response;
  3. import org.elasticsearch.client.RestClient;
  4. import org.elasticsearch.client.RestClientBuilder;

Now you can connect to ElasticSearch.

  1. final RestClientBuilder restClientBuilder = RestClient.builder(new HttpHost("localhost", 9200, "http"));
  2. final RestClient restClient = builder.build();

Now you can do whatever you need to!

Series NavigationElasticSearch: Low Level Client Put >>

2 thoughts on “ElasticSearch: Low Level Rest Client Connection”

Comments are closed.