Creating a client
The official Elasticsearch clients are designed to manage a lot of issues that are typically required to create solid REST clients, such as retry
if there are network issues, autodiscovery of other nodes in the cluster, and data conversions for communicating on the HTTP layer.
In this recipe, we'll learn how to instantiate a client with varying options.
Getting ready
You will need an up-and-running Elasticsearch installation, which we described how to get in the Downloading and installing Elasticsearch recipe in Chapter 1, Getting Started.
A Python 3.x distribution should be installed. On Linux and macOS systems, it's already provided in the standard installation. To manage Python, you must also install the necessary pip
packages (https://pypi.python.org/pypi/pip/).
The full code for this recipe can be found in the ch15/code/client_creation.py
file.
How to do it...
To create a client, perform the following steps:
- Before you can...