Bird
0
0

Which of the following is the correct syntax to update the field status to "active" in a document with ID 1 in index users?

easy📝 Syntax Q12 of 15
Elasticsearch - Document Operations
Which of the following is the correct syntax to update the field status to "active" in a document with ID 1 in index users?
APUT /users/_update/1 { "status": "active" }
BGET /users/_update/1 { "doc": { "status": "active" } }
CPOST /users/_update/1 { "doc": { "status": "active" } }
DPOST /users/_doc/1 { "status": "active" }
Step-by-Step Solution
Solution:
  1. Step 1: Identify the correct HTTP method and endpoint

    The update API uses POST method with the path /index/_update/document_id.
  2. Step 2: Check the request body format

    The fields to update must be inside the doc object. POST /users/_update/1 { "doc": { "status": "active" } } matches this format exactly.
  3. Final Answer:

    POST /users/_update/1 { "doc": { "status": "active" } } -> Option C
  4. Quick Check:

    Use POST with _update and doc object [OK]
Quick Trick: Use POST with _update and put fields inside doc [OK]
Common Mistakes:
MISTAKES
  • Using GET instead of POST for update
  • Omitting the doc wrapper in the body
  • Using _doc endpoint instead of _update

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes