0
0
Elasticsearchquery~20 mins

Why mappings define document structure in Elasticsearch - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Mapping Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this mapping definition?
Given this Elasticsearch mapping snippet, what will be the data type of the field age in the index?
Elasticsearch
{
  "mappings": {
    "properties": {
      "name": { "type": "text" },
      "age": { "type": "integer" }
    }
  }
}
A"age" will be treated as a string field.
B"age" will be treated as an integer field.
C"age" will be treated as a date field.
D"age" will be treated as a boolean field.
Attempts:
2 left
💡 Hint
Look at the type assigned to the "age" field inside the mapping.
🧠 Conceptual
intermediate
1:30remaining
Why do mappings matter in Elasticsearch?
Why is it important to define mappings before indexing documents in Elasticsearch?
AMappings are only used to store documents, not to search them.
BMappings automatically fix errors in documents during indexing.
CMappings allow Elasticsearch to know how to index and search each field correctly.
DMappings slow down the indexing process and should be avoided.
Attempts:
2 left
💡 Hint
Think about how Elasticsearch uses mappings to understand data.
🔧 Debug
advanced
2:00remaining
Identify the error in this mapping snippet
This mapping is intended to define a date field named created_at. What is wrong with it?
Elasticsearch
{
  "mappings": {
    "properties": {
      "created_at": { "type": "dates" }
    }
  }
}
AThe type "dates" is invalid; it should be "date".
BThe field name "created_at" is not allowed in mappings.
CThe mapping is missing a "format" property for the date.
DThere is no error; this mapping is correct.
Attempts:
2 left
💡 Hint
Check the spelling of the data type.
📝 Syntax
advanced
2:30remaining
Which mapping snippet is syntactically correct?
Choose the mapping snippet that is valid JSON and correctly defines a nested field address with city and zipcode as text fields.
A{ "mappings": { "properties": { "address": { "type": "nested", "properties": { "city": { "type": "text" }, "zipcode": { "type": "text" } } } } } }
B{ "mappings": { "properties": { "address": { "nested": true, "fields": { "city": "text", "zipcode": "text" } } } } }
C{ "mappings": { "properties": { "address": { "type": "object", "city": { "type": "text" }, "zipcode": { "type": "text" } } } } }
D{ "mappings": { "properties": { "address": { "type": "nested", "city": { "type": "text" }, "zipcode": { "type": "text" } } } } }
Attempts:
2 left
💡 Hint
Look for the correct use of "type": "nested" and the "properties" keyword.
🚀 Application
expert
3:00remaining
How many fields will be indexed in this mapping?
Given this mapping, how many fields will Elasticsearch index for each document?
Elasticsearch
{
  "mappings": {
    "properties": {
      "user": {
        "properties": {
          "name": { "type": "text" },
          "email": { "type": "keyword" }
        }
      },
      "tags": { "type": "keyword" },
      "comments": {
        "type": "nested",
        "properties": {
          "author": { "type": "text" },
          "message": { "type": "text" }
        }
      }
    }
  }
}
A6 fields
B4 fields
C3 fields
D5 fields
Attempts:
2 left
💡 Hint
Count all leaf fields inside properties, including nested ones.