Bird
0
0

Which of the following is the correct format for a single action in the Elasticsearch Bulk API?

easy📝 Syntax Q12 of 15
Elasticsearch - Document Operations
Which of the following is the correct format for a single action in the Elasticsearch Bulk API?
A{"index": {"_index": "test", "_id": "1", "field": "value"}}
B{"index": {"_index": "test", "_id": "1"}} {"field": "value"}
C[{"index": {"_index": "test", "_id": "1"}}, {"field": "value"}]
D{"field": "value"} {"index": {"_index": "test", "_id": "1"}}
Step-by-Step Solution
Solution:
  1. Step 1: Recall Bulk API action format

    Each action in Bulk API consists of two JSON lines: first metadata (like index and id), then the document data.
  2. Step 2: Check options for correct order and format

    Combining metadata and data in one JSON object is invalid. The reversed order with data line before metadata line is wrong. Using a JSON array is invalid. {"index": {"_index": "test", "_id": "1"}} {"field": "value"} correctly shows metadata line followed by data line.
  3. Final Answer:

    {"index": {"_index": "test", "_id": "1"}} {"field": "value"} -> Option B
  4. Quick Check:

    Metadata line then data line = correct Bulk format [OK]
Quick Trick: Metadata line first, then data line in Bulk API [OK]
Common Mistakes:
MISTAKES
  • Swapping metadata and data lines
  • Using JSON arrays instead of lines
  • Combining metadata and data in one JSON object

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes