LearnThatStack Ace your next interview
Elasticsearch · question
Question 4 of 49

How do you perform CRUD operations on documents?

beginner
← All Elasticsearch questions
Re-explain

You perform CRUD on Elasticsearch documents with the document APIs. Each operation is one HTTP request to a path made of the index name and the document ID.

To create a document, or replace it if the ID exists, send PUT with the JSON body. This is called indexing a document.

PUT /users/_doc/1
{
  "name": "John Doe",
  "email": "john@example.com",
  "age": 30
}

To read it, send GET to the same path.

GET /users/_doc/1

To change only some fields, use the update API. It merges the partial doc into the stored document.

POST /users/_update/1
{
  "doc": {
    "age": 31
  }
}

To delete it, send DELETE to the same path.

DELETE /users/_doc/1

For many documents, the bulk API sends many operations in one request. The body is newline-delimited JSON, with an action line before each document. Bulk requests are much faster than one request per document, which matters for large loads.

POST /_bulk
{"index": {"_index": "users", "_id": "1"}}
{"name": "Alice", "age": 25}
{"index": {"_index": "users", "_id": "2"}}
{"name": "Bob", "age": 30}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the Elasticsearch cheatsheet.

← Back to all Elasticsearch questions
Pro · $10/mo

44 of 49 Elasticsearch answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime