Bird
0
0

Which of the following is the correct syntax to index a document with ID "101" in the index "library" using PUT?

easy📝 Syntax Q3 of 15
Elasticsearch - Document Operations
Which of the following is the correct syntax to index a document with ID "101" in the index "library" using PUT?
APOST /library/_doc {"title": "Book"}
BPUT /library/_doc/101 {"title": "Book"}
CPUT /library/_doc {"title": "Book"}
DPOST /library/_doc/101 {"title": "Book"}
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct HTTP method and URL

    PUT with document ID in URL is correct for indexing with ID.
  2. Step 2: Check JSON body placement

    The JSON document follows the URL in the request body.
  3. Final Answer:

    PUT /library/_doc/101 {"title": "Book"} -> Option B
  4. Quick Check:

    PUT with ID in URL syntax = PUT /library/_doc/101 {"title": "Book"} [OK]
Quick Trick: PUT requires ID in URL, POST does not [OK]
Common Mistakes:
MISTAKES
  • Using POST with ID in URL
  • Omitting ID in PUT request
  • Wrong HTTP method for given syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes