Connecting to Elasticsearch with Java

For Legacy Support Purposes Only

There are a few ways to write Java client for Elasticsearch. Here we are using Java High-Level REST Client. Make sure you have Java 1.8 or higher version. In order to use Java High-Level REST Client, you need to add the following dependencies to the project.

  1. Authentication to Elasticsearch Cluster
  2. Connecting to cluster
  3. Indexing
  4. Getting a document

Full sample code