Bird
Raised Fist0
Elasticsearchquery~20 mins

Deleting and closing indexes in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Elasticsearch Index Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
What is the output of closing an index?
You run the following command to close an index named my_index. What is the expected response status in the output?
Elasticsearch
POST /my_index/_close
A{"acknowledged":true}
B{"closed":true}
C{"status":"closed"}
D{"result":"closed"}
Attempts:
2 left
💡 Hint
Closing an index returns an acknowledgement from Elasticsearch.
❓ Predict Output
intermediate
2:00remaining
What happens when deleting a non-existing index?
You try to delete an index named unknown_index that does not exist. What is the typical response status?
Elasticsearch
DELETE /unknown_index
A{"acknowledged":true}
B{"error":{"type":"index_not_found_exception"}}
C{"result":"not_found"}
D{"status":"deleted"}
Attempts:
2 left
💡 Hint
Elasticsearch returns an error if the index does not exist when deleting.
🧠 Conceptual
advanced
2:00remaining
Which statement about closing indexes is true?
Select the correct statement about closing an Elasticsearch index.
AClosed indexes remain writable but are hidden from searches.
BClosing an index frees up disk space by deleting all data.
CClosing an index automatically deletes its mappings.
DA closed index cannot be searched until it is reopened.
Attempts:
2 left
💡 Hint
Think about what closing means for index accessibility.
❓ Predict Output
advanced
2:00remaining
What is the output after reopening a closed index?
You closed an index logs_2023 and then reopened it using POST /logs_2023/_open. What is the expected output?
Elasticsearch
POST /logs_2023/_open
A{"acknowledged":true}
B{"opened":true}
C{"result":"opened"}
D{"status":"open"}
Attempts:
2 left
💡 Hint
Opening an index returns an acknowledgement similar to closing.
❓ Predict Output
expert
2:00remaining
What error occurs when deleting a closed index with aliases?
You have a closed index archive_2022 with an alias archive. You try to delete it using DELETE /archive_2022. What error will Elasticsearch return?
Elasticsearch
DELETE /archive_2022
A{"error":{"type":"index_closed_exception"}}
B{"acknowledged":true}
C{"error":{"type":"illegal_argument_exception","reason":"Cannot delete index with aliases"}}
D{"error":{"type":"alias_not_found_exception"}}
Attempts:
2 left
💡 Hint
Deleting an index with aliases is restricted.

Practice

(1/5)
1. What happens when you delete an index in Elasticsearch?
easy
A. The index is temporarily hidden but data remains.
B. The index and all its data are permanently removed.
C. The index is locked for editing but still searchable.
D. The index is backed up automatically before removal.

Solution

  1. Step 1: Understand the delete operation

    Deleting an index removes it completely from Elasticsearch, including all stored data.
  2. Step 2: Compare with closing an index

    Closing an index only frees resources but keeps data safe, unlike deleting.
  3. Final Answer:

    The index and all its data are permanently removed. -> Option B
  4. Quick Check:

    Delete = permanent removal [OK]
Hint: Delete means gone forever, close means temporary [OK]
Common Mistakes:
  • Confusing delete with close operation
  • Thinking data is saved after delete
  • Assuming delete backs up data automatically
2. Which is the correct syntax to close an index named my_index in Elasticsearch?
easy
A. DELETE /my_index/_close
B. PUT /my_index/_close
C. POST /my_index/_close
D. GET /my_index/_close

Solution

  1. Step 1: Identify the HTTP method for closing

    Closing an index uses the POST method with the _close endpoint.
  2. Step 2: Verify the endpoint and method

    POST /my_index/_close is the correct syntax to close the index named my_index.
  3. Final Answer:

    POST /my_index/_close -> Option C
  4. Quick Check:

    Close uses POST with _close [OK]
Hint: Close uses POST method with _close endpoint [OK]
Common Mistakes:
  • Using DELETE instead of POST
  • Using GET or PUT for closing
  • Missing the _close suffix in URL
3. What will be the result of this sequence of commands?
DELETE /test_index
POST /test_index/_close
GET /test_index/_settings
medium
A. Index deleted, error on close, error on get settings
B. Index deleted, close ignored, settings returned
C. Index closed successfully, settings returned
D. Error on DELETE, index remains open, settings returned

Solution

  1. Step 1: Analyze DELETE command

    The DELETE command removes test_index permanently.
  2. Step 2: Analyze POST close command after deletion

    Since the index is deleted, trying to close it causes an error because it no longer exists.
  3. Step 3: Analyze GET settings command

    Getting settings for a deleted index also results in an error as the index is gone.
  4. Final Answer:

    Index deleted, error on close, error on get settings -> Option A
  5. Quick Check:

    Delete removes index, later commands fail [OK]
Hint: Delete first means index gone, next commands fail [OK]
Common Mistakes:
  • Assuming close works after delete
  • Expecting settings for deleted index
  • Thinking delete only hides index
4. You tried to close an index with POST /myindex/_close but got a 404 error. What is the most likely cause?
medium
A. The index is already closed.
B. You used the wrong HTTP method; DELETE is required.
C. You need to delete the index before closing it.
D. The index myindex does not exist.

Solution

  1. Step 1: Understand error causes for closing

    Closing an index fails if the index does not exist in Elasticsearch.
  2. Step 2: Check other options

    A 404 specifically indicates the index does not exist. The index is already closed. (already closed) causes a 400 error. POST is the correct method, not DELETE (B). Deleting before closing is not required (D).
  3. Final Answer:

    The index myindex does not exist. -> Option D
  4. Quick Check:

    Close error usually means index missing [OK]
Hint: Close errors usually mean index missing [OK]
Common Mistakes:
  • Using DELETE instead of POST
  • Thinking index must be deleted before closing
  • Assuming error means index already closed
5. You want to temporarily free resources by closing an index but keep its data safe. Later, you want to reopen it. Which sequence of commands should you use?
hard
A. POST /myindex/_close then POST /myindex/_open
B. DELETE /myindex then POST /myindex/_open
C. POST /myindex/_open then POST /myindex/_close
D. PUT /myindex/_close then DELETE /myindex

Solution

  1. Step 1: Close index to free resources

    Use POST /myindex/_close to close the index without deleting data.
  2. Step 2: Reopen index when needed

    Use POST /myindex/_open to reopen the closed index and make it searchable again.
  3. Final Answer:

    POST /myindex/_close then POST /myindex/_open -> Option A
  4. Quick Check:

    Close then open to save and restore resources [OK]
Hint: Close with POST _close, reopen with POST _open [OK]
Common Mistakes:
  • Deleting index instead of closing
  • Opening before closing
  • Using wrong HTTP methods like PUT or DELETE
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard