Managing documents
The APIs for managing a document (index, update, and delete) are the most important after the search APIs. In this recipe, you will learn how to use them in a standard way and use bulk actions to improve performance.
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.
You will also need the Python packages that we installed in the Creating a client recipe in this chapter.
The full code for this recipe can be found in the ch15/code/document_management.py
file.
How to do it…
The three main operations you can use to manage documents are as follows:
index
: This operation stores a document in Elasticsearch. It is mapped to theindex
API call.update
: This allows you to update values in a document. This operation is composed internally (via Lucene) by deleting the previous document and reindexing...