Managing mappings
After creating an index, the next step is to add some type mappings to it. We saw how to put a mapping via the REST API in Chapter 4, Basic Operations. In this recipe, we will see how to manage mappings via the official Python client and PyES.
Getting ready
You need a working ElasticSearch cluster and the required packages that are used in the Creating a client recipe in this chapter.
The code of this recipe is present in chapter_11/mapping_management.py
and chapter_11/mapping_management_pyes.py
file, which is available in the code bundle of this book and on GitHub (https://github.com/aparo/elasticsearch-cookbook-second-edition).
How to do it...
After you have initialized a client and created an index, the following actions are available in order to manage the indices:
- Creating a mapping
- Retrieving a mapping
- Deleting a mapping
These steps can be easily managed with the following code:
- Use the following code to initialize the client:
import elasticsearch es = elasticsearch.Elasticsearch...