CRUD Operations

Understand how CRUD operations are used in Elasticsearch.

Create, read, update, and delete (CRUD) operations

Elasticsearch provides a set of APIs that allow users to perform various operations on the data, including create, read, update, and delete operations. These operations are crucial for managing data in Elasticsearch, and they enable users to add, retrieve, modify, and remove data from the index. In this context, it is important to understand the basics of these operations, how they work, and how to use them effectively to manipulate data in Elasticsearch.

Press + to interact

We will create a movie index prior to explaining CRUD operations, so that we can use it to perform the required operations. The index will serve as the storage location for movie-related data and enable us to create, read, update, and delete information in Elasticsearch.

Note: It’s important to remember to test each request we create in the lesson by visiting the “Kibana widget” section at the end of the lesson.

The following request creates a movie index:

PUT movie

Creating (indexing) a document

The create operation in Elasticsearch is commonly known as indexing a document, and it refers to adding a new document to an index.

There are multiple ways to index a document in Elasticsearch:

  • Indexing a document with an autogenerated ID
  • Indexing a document with a specified ID

Indexing a document with an autogenerated ID

To index a document in Elasticsearch, one method is to allow Elasticsearch to generate an ID for the document automatically. When sending a request to index a document, Elasticsearch ...