Bird
0
0

This indexing request fails:

medium📝 Debug Q7 of 15
Elasticsearch - Document Operations
This indexing request fails:
PUT /orders/_doc/123
{ "item": "laptop" }

But the error says the document already exists and cannot be created. What is the fix?
AUse POST instead of PUT to create the document.
BChange the document ID to a new unique value.
CAdd "op_type": "create" to allow overwriting.
DRemove "op_type": "create" or use "op_type": "index" to allow updates.
Step-by-Step Solution
Solution:
  1. Step 1: Understand "op_type": "create" behavior

    This option forbids overwriting existing documents; it errors if ID exists.
  2. Step 2: Fix the error by allowing updates

    Removing "op_type": "create" or setting it to "index" allows overwriting the document with the same ID.
  3. Final Answer:

    Remove "op_type": "create" or use "op_type": "index" to allow updates. -> Option D
  4. Quick Check:

    "op_type": "create" forbids overwrites [OK]
Quick Trick: Use "op_type": "index" to allow document updates [OK]
Common Mistakes:
MISTAKES
  • Using POST instead of fixing op_type
  • Adding "op_type": "create" causes error
  • Changing ID unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes