Bird
0
0

Which of the following is the correct Elasticsearch request to set the status field to "active" for the document with ID 123 in the users index?

easy📝 Syntax Q3 of 15
Elasticsearch - Document Operations
Which of the following is the correct Elasticsearch request to set the status field to "active" for the document with ID 123 in the users index?
APOST /users/_update { "id": "123", "status": "active" }
BPUT /users/_doc/123 { "status": "active" }
CPOST /users/_update/123 { "doc": { "status": "active" } }
DGET /users/_update/123 { "doc": { "status": "active" } }
Step-by-Step Solution
Solution:
  1. Step 1: Identify the correct HTTP method and endpoint

    Updating a document field uses POST with _update and the document ID in the URL.
  2. Step 2: Confirm the request body format

    The update body must include a doc object specifying the fields to update.
  3. Step 3: Validate options

    POST /users/_update/123 { "doc": { "status": "active" } } matches the correct syntax. PUT /users/_doc/123 { "status": "active" } uses PUT and replaces the whole document. POST /users/_update { "id": "123", "status": "active" } is invalid syntax. GET /users/_update/123 { "doc": { "status": "active" } } uses GET which is incorrect for updates.
  4. Final Answer:

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

    Use POST _update with doc for partial updates [OK]
Quick Trick: Use POST _update with doc to update fields [OK]
Common Mistakes:
MISTAKES
  • Using PUT instead of POST for partial updates
  • Omitting the doc wrapper in the request body
  • Using GET method for updates

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes