Book Image

ElasticSearch Cookbook

By : Alberto Paro
Book Image

ElasticSearch Cookbook

By: Alberto Paro

Overview of this book

Table of Contents (20 chapters)
ElasticSearch Cookbook Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Managing documents


The APIs for managing documents (indexing, updating, and deleting) are the most important APIs after the search ones. In this recipe, we will see how to use them in a standard way and in bulk actions to improve performance.

Getting ready

You need a working ElasticSearch cluster and the packages used in the Creating a client recipe of this chapter.

The full code of this recipe is in the chapter_11/document_management.py and chapter_11/document_management_pyes.py files, available in the code bundle of this book and on GitHub (https://github.com/aparo/elasticsearch-cookbook-second-edition).

How to do it...

There are three main operations to manage documents, as follows:

  • index: This stores a document in ElasticSearch. It is mapped on the Index API call.

  • update: This allows you to update some values in a document. This operation is composed internally (via Lucene) by deleting the previous documents and reindexing the document with new values. It is mapped to the Update API call...