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 ...

Get Elasticsearch 5.x Cookbook - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.