Creating an HTTP Elasticsearch client
With Elasticsearch 5.x, the Elasticsearch team has provided a custom low-level HTTP client to communicate with Elasticsearch. Its main features are as follows:
Minimal dependencies
Load balancing across all available nodes
Failover in the case of node failures and upon specific response codes
Failed connection penalization (whether a failed node is retried depends on how many consecutive times it failed; the more failed attempts, the longer the client will wait before trying that same node again)
Persistent connections
Trace logging of requests and responses
Optional automatic discovery of cluster nodes
Getting ready
You need an up-and-running Elasticsearch installation as we described in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup.
A Maven tool, or an IDE that natively supports it for Java programming such as Eclipse or IntelliJ IDEA, must be installed.
The code for this recipe is in the chapter_14/http_es_client
directory...