Creating a low-level Elasticsearch client
There are two official Elasticsearch clients: the low-level one and the new typed one available from Elasticsearch 8.x (https://github.com/elastic/elasticsearch-java). The low-level one is used to communicate with Elasticsearch, and 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, which can be obtained as described in the Downloading and installing Elasticsearch recipe in Chapter 1, Getting Started.
To...