Creating a client
The official Elasticsearch clients are designed to manage a lot of issues that typically are required to create solid REST clients, such as retry
if there are network issues, autodiscovery of other nodes of the cluster, and data conversions for communicating on the HTTP layer.
In this recipe, we'll see how to instantiate a client with varying options.
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 Python 2.x or 3.x distribution should be installed. In Linux and the MacOsX system, it's already provided by the standard installation. To manage Python, pip
packages (https://pypi.python.org/pypi/pip/) must be also installed.
The full code of this recipe is in the chapter_16/client_creation.py
file.
How to do it...
For creating a client, we will perform the following steps:
Before using the Python client, we need to install it (possibly in a Python virtual...