Creating a native client
There are two ways to create a native client to communicate with an Elasticsearch server:
Creating a transport client: This is a standard client that requires the address and port of nodes to connect to.
Creating a client or coordinating only one node (it's a node that is not a data, master, or ingest node) and get the client from it. This node will appear in the cluster state nodes and can use the discovery capabilities of Elasticsearch to join the cluster (so no node address is required to connect to a cluster). This kind of client can reduce node routing due to knowledge of cluster topology. It can also load Elasticsearch plugins.
In this recipe, we will see how to create these clients.
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...