Recall & Review
beginner
What does indexing a document mean in Elasticsearch?
Indexing a document means storing or updating a document in an Elasticsearch index so it can be searched and retrieved later.
Click to reveal answer
beginner
Which HTTP methods are commonly used to index a document in Elasticsearch?
POST and PUT are used to index documents. POST creates a new document with an auto-generated ID, while PUT creates or updates a document with a specified ID.
Click to reveal answer
intermediate
What is the difference between POST and PUT when indexing a document?
POST adds a new document with a generated ID. PUT adds or replaces a document with a specific ID you provide.
Click to reveal answer
beginner
Show a simple example of indexing a document using POST in Elasticsearch.
POST /my-index/_doc
{
"title": "My first document",
"content": "This is the content of the document."
}
This adds a new document with an auto-generated ID to 'my-index'.
Click to reveal answer
intermediate
What happens if you use PUT to index a document with an existing ID?
The existing document with that ID is replaced with the new document you send. If the ID does not exist, a new document is created.
Click to reveal answer
Which HTTP method automatically generates a document ID when indexing in Elasticsearch?
✗ Incorrect
POST creates a new document with an auto-generated ID, while PUT requires you to specify the ID.
What is the correct URL format to index a document with a specified ID '123' in index 'books'?
✗ Incorrect
PUT or POST to /books/_doc/123 indexes the document with ID '123' in the 'books' index.
If you want to update an existing document, which method should you use?
✗ Incorrect
PUT with the document ID replaces or updates the document at that ID.
What happens if you POST a document to an index that does not exist?
✗ Incorrect
Elasticsearch automatically creates the index if it does not exist when you index a document.
Which part of the request contains the actual data of the document when indexing?
✗ Incorrect
The document data is sent in the request body as JSON.
Explain how to index a new document in Elasticsearch using POST and what happens behind the scenes.
Think about what POST does with the document and the ID.
You got /4 concepts.
Describe the difference between using POST and PUT for indexing documents in Elasticsearch.
Focus on how IDs are handled and document updates.
You got /4 concepts.