Bird
0
0

Which JSON correctly defines this index?

hard🚀 Application Q8 of 15
Elasticsearch - Index Management
You need to create an Elasticsearch index named profiles with 1 shard and 1 replica. The index should have fields: username (keyword), age (integer), and bio (text). Which JSON correctly defines this index?
A{ "settings": { "number_of_shards": 1, "number_of_replicas": 1 }, "mappings": { "properties": { "username": { "type": "keyword" }, "age": { "type": "integer" }, "bio": { "type": "text" } } } }
B{ "settings": { "shards": 1, "replicas": 1 }, "mappings": { "fields": { "username": "keyword", "age": "integer", "bio": "text" } } }
C{ "settings": { "number_of_shards": "one", "number_of_replicas": "one" }, "mappings": { "properties": { "username": { "type": "keyword" }, "age": { "type": "integer" }, "bio": { "type": "text" } } } }
D{ "settings": { "number_of_shards": 1 }, "mapping": { "properties": { "username": { "type": "keyword" }, "age": { "type": "integer" }, "bio": { "type": "text" } } } }
Step-by-Step Solution
Solution:
  1. Step 1: Verify settings syntax

    { "settings": { "number_of_shards": 1, "number_of_replicas": 1 }, "mappings": { "properties": { "username": { "type": "keyword" }, "age": { "type": "integer" }, "bio": { "type": "text" } } } } correctly uses "number_of_shards" and "number_of_replicas" with integer values.
  2. Step 2: Check mappings structure

    { "settings": { "number_of_shards": 1, "number_of_replicas": 1 }, "mappings": { "properties": { "username": { "type": "keyword" }, "age": { "type": "integer" }, "bio": { "type": "text" } } } } uses "mappings" with "properties" defining each field and its type properly.
  3. Step 3: Identify errors in other options

    { "settings": { "shards": 1, "replicas": 1 }, "mappings": { "fields": { "username": "keyword", "age": "integer", "bio": "text" } } } uses incorrect keys "shards" and "replicas" and wrong mapping structure.
    { "settings": { "number_of_shards": "one", "number_of_replicas": "one" }, "mappings": { "properties": { "username": { "type": "keyword" }, "age": { "type": "integer" }, "bio": { "type": "text" } } } } uses strings instead of integers for shard and replica counts.
    { "settings": { "number_of_shards": 1 }, "mapping": { "properties": { "username": { "type": "keyword" }, "age": { "type": "integer" }, "bio": { "type": "text" } } } } misspells "mappings" as "mapping".
  4. Final Answer:

    { "settings": { "number_of_shards": 1, "number_of_replicas": 1 }, "mappings": { "properties": { "username": { "type": "keyword" }, "age": { "type": "integer" }, "bio": { "type": "text" } } } } is the correct JSON structure.
  5. Quick Check:

    Correct keys and types are essential in index creation JSON [OK]
Quick Trick: Use correct keys and integer values in settings [OK]
Common Mistakes:
MISTAKES
  • Using strings instead of integers for shards/replicas
  • Misspelling 'mappings' as 'mapping'
  • Incorrect keys like 'shards' instead of 'number_of_shards'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes