0
0
Elasticsearchquery~20 mins

Creating an index in Elasticsearch - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Elasticsearch Index Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the output of this index creation request?

Given the following Elasticsearch request to create an index named library with a simple mapping, what will be the response status?

Elasticsearch
{
  "mappings": {
    "properties": {
      "title": { "type": "text" },
      "author": { "type": "keyword" },
      "year": { "type": "integer" }
    }
  }
}
A{"acknowledged":true,"shards_acknowledged":true,"index":"library"}
B{"error":"index_already_exists_exception","status":400}
C{"acknowledged":false,"shards_acknowledged":false,"index":"library"}
D{"error":"illegal_argument_exception","status":400}
Attempts:
2 left
💡 Hint

Successful index creation returns acknowledged: true.

🧠 Conceptual
intermediate
1:30remaining
Which setting controls the number of primary shards when creating an index?

When creating an Elasticsearch index, which setting defines how many primary shards the index will have?

A"number_of_replicas"
B"refresh_interval"
C"index_buffer_size"
D"number_of_shards"
Attempts:
2 left
💡 Hint

Think about how data is split across the cluster.

📝 Syntax
advanced
2:30remaining
Which JSON snippet correctly creates an index with 3 replicas?

Select the correct JSON body to create an Elasticsearch index named products with 1 primary shard and 3 replicas.

A
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 3
  }
}
B
{
  "settings": {
    "shards": 1,
    "replicas": 3
  }
}
C
{
  "settings": {
    "number_of_shards": "1",
    "number_of_replicas": "3"
  }
}
D
{
  "settings": {
    "number_of_shards": 3,
    "number_of_replicas": 1
  }
}
Attempts:
2 left
💡 Hint

Settings keys must be exact and values numeric, not strings.

🔧 Debug
advanced
2:00remaining
Why does this index creation fail?

Consider this request to create an index named users with a mapping:

{
  "mappings": {
    "properties": {
      "name": { "type": "text" },
      "age": { "type": "integer" },
      "email": { "type": "keyword" }
    }
  },
  "settings": {
    "number_of_shards": 0
  }
}

Why will this request fail?

ABecause <code>mappings</code> must be inside <code>settings</code>
BBecause <code>integer</code> type is not allowed in mappings
CBecause <code>number_of_shards</code> cannot be zero; it must be at least 1
DBecause <code>keyword</code> type is invalid for <code>email</code>
Attempts:
2 left
💡 Hint

Think about shard count limits.

optimization
expert
3:00remaining
Which index setting improves search speed by disabling _source storage?

You want to optimize an Elasticsearch index for search speed and reduce storage size. Which setting disables storing the original JSON document and can improve performance?

A"store": { "enabled": false }
B"_source": { "enabled": false }
C"index.store.type": "none"
D"refresh_interval": "-1"
Attempts:
2 left
💡 Hint

The original JSON document is stored in a special field called _source.