Bird
0
0

Which of the following is the correct syntax to index a document with a manual ID in Elasticsearch using JSON?

easy📝 Syntax Q12 of 15
Elasticsearch - Document Operations
Which of the following is the correct syntax to index a document with a manual ID in Elasticsearch using JSON?
A{ "index": "my_index", "_id": "123", "body": { "name": "Alice" } }
B{ "index": "my_index", "id": "123", "body": { "name": "Alice" } }
C{ "index": "my_index", "id": 123, "doc": { "name": "Alice" } }
D{ "index": "my_index", "_id": 123, "doc": { "name": "Alice" } }
Step-by-Step Solution
Solution:
  1. Step 1: Identify the correct field for manual ID

    Elasticsearch uses "_id" (with underscore) to specify manual document IDs.
  2. Step 2: Check the correct structure for indexing

    The "body" key holds the document content; "doc" is used for updates, not indexing.
  3. Final Answer:

    { "index": "my_index", "_id": "123", "body": { "name": "Alice" } } -> Option A
  4. Quick Check:

    Manual ID uses "_id" and "body" for document [OK]
Quick Trick: Use "_id" for manual IDs and "body" for document content [OK]
Common Mistakes:
MISTAKES
  • Using "id" instead of "_id"
  • Confusing "doc" with "body" for indexing
  • Passing numeric ID without quotes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes