Elasticsearch - Document OperationsWhich 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" } }Check Answer
Step-by-Step SolutionSolution:Step 1: Identify the correct field for manual IDElasticsearch uses "_id" (with underscore) to specify manual document IDs.Step 2: Check the correct structure for indexingThe "body" key holds the document content; "doc" is used for updates, not indexing.Final Answer:{ "index": "my_index", "_id": "123", "body": { "name": "Alice" } } -> Option AQuick 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:MISTAKESUsing "id" instead of "_id"Confusing "doc" with "body" for indexingPassing numeric ID without quotes
Master "Document Operations" in Elasticsearch9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Elasticsearch Quizzes Basic Search Queries - Bool query (must, should, must_not, filter) - Quiz 5medium Basic Search Queries - Match query - Quiz 9hard Document Operations - Bulk API for batch operations - Quiz 3easy Document Operations - Bulk API for batch operations - Quiz 13medium Document Operations - Indexing a document (POST/PUT) - Quiz 3easy Elasticsearch Basics and Architecture - Why Elasticsearch exists - Quiz 6medium Elasticsearch Basics and Architecture - Inverted index data structure - Quiz 14medium Index Management - Index mappings overview - Quiz 6medium Mappings and Data Types - Dynamic vs explicit mapping - Quiz 10hard Search Results and Scoring - Highlighting matched text - Quiz 1easy