Bird
Raised Fist0
Elasticsearchquery~10 mins

Dynamic vs explicit mapping in Elasticsearch - Interactive Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable dynamic mapping in Elasticsearch index creation.

Elasticsearch
{
  "mappings": {
    "dynamic": [1]
  }
}
Drag options to blanks, or click blank then click option'
A"strict"
BTrue
CFalse
D"enabled"
Attempts:
3 left
💡 Hint
Common Mistakes
Using string "true" instead of boolean true.
Confusing true with invalid "enabled".
2fill in blank
medium

Complete the explicit mapping to define a text field with keyword subfield.

Elasticsearch
{
  "properties": {
    "title": {
      "type": [1],
      "fields": {
        "keyword": {
          "type": "keyword"
        }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
A"text"
B"date"
C"keyword"
D"integer"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'keyword' as main type instead of 'text'.
Confusing 'integer' or 'date' types for text fields.
3fill in blank
hard

Fix the error in the mapping to disable dynamic mapping.

Elasticsearch
{
  "mappings": {
    "dynamic": [1]
  }
}
Drag options to blanks, or click blank then click option'
AFalse
B"enabled"
CTrue
D"disabled"
Attempts:
3 left
💡 Hint
Common Mistakes
Using string "false" instead of boolean false.
Using "disabled" which is not a valid value.
4fill in blank
hard

Fill both blanks to define an explicit mapping for a date field with a custom format.

Elasticsearch
{
  "properties": {
    "created_at": {
      "type": [1],
      "format": [2]
    }
  }
}
Drag options to blanks, or click blank then click option'
A"date"
B"text"
C"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd"
D"keyword"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'text' or 'keyword' as type for date fields.
Not providing the format string or using wrong format.
5fill in blank
hard

Fill all three blanks to create a mapping with dynamic disabled, and explicit properties for name and age.

Elasticsearch
{
  "dynamic": [1],
  "properties": {
    "name": {
      "type": [2]
    },
    "age": {
      "type": [3]
    }
  }
}
Drag options to blanks, or click blank then click option'
AFalse
B"text"
C"integer"
D"keyword"
Attempts:
3 left
💡 Hint
Common Mistakes
Using string "false" instead of boolean false.
Confusing 'keyword' with 'text' for name field.
Using 'text' for age instead of 'integer'.

Practice

(1/5)
1. What is the main difference between dynamic mapping and explicit mapping in Elasticsearch?
easy
A. Dynamic mapping automatically detects field types, explicit mapping requires manual definition.
B. Dynamic mapping requires manual field type definition, explicit mapping guesses types automatically.
C. Dynamic mapping disables indexing, explicit mapping enables indexing.
D. Dynamic mapping is only for text fields, explicit mapping is only for numeric fields.

Solution

  1. Step 1: Understand dynamic mapping

    Dynamic mapping lets Elasticsearch guess the data type of fields automatically when new data arrives.
  2. Step 2: Understand explicit mapping

    Explicit mapping means you define each field's type and settings manually before indexing data.
  3. Final Answer:

    Dynamic mapping automatically detects field types, explicit mapping requires manual definition. -> Option A
  4. Quick Check:

    Dynamic = auto detect, Explicit = manual define [OK]
Hint: Dynamic guesses types; explicit means you set types yourself [OK]
Common Mistakes:
  • Confusing which mapping guesses types
  • Thinking dynamic disables indexing
  • Assuming explicit mapping is only for numbers
2. Which JSON snippet correctly defines an explicit mapping for a field age as an integer?
easy
A. {"mappings": {"properties": {"age": "number"}}}
B. {"mappings": {"age": {"type": "text"}}}
C. {"properties": {"age": "integer"}}
D. {"mappings": {"properties": {"age": {"type": "integer"}}}}

Solution

  1. Step 1: Check correct mapping structure

    Explicit mapping requires "mappings" with "properties" and field name with type inside.
  2. Step 2: Verify field type for age

    "age" field must have "type": "integer" to define it as integer.
  3. Final Answer:

    {"mappings": {"properties": {"age": {"type": "integer"}}}} -> Option D
  4. Quick Check:

    Correct JSON structure with integer type [OK]
Hint: Explicit mapping needs mappings > properties > field > type [OK]
Common Mistakes:
  • Missing 'properties' level in JSON
  • Using wrong type names like 'number' instead of 'integer'
  • Placing fields outside 'mappings'
3. Given this explicit mapping, what will be the type of the price field after indexing?
{"mappings": {"properties": {"price": {"type": "float"}}}}
medium
A. integer
B. text
C. float
D. keyword

Solution

  1. Step 1: Read the explicit mapping for price

    The mapping defines "price" with "type": "float", so Elasticsearch will store it as a floating-point number.
  2. Step 2: Understand type assignment

    Explicit mapping overrides dynamic guessing, so price will be float regardless of input data.
  3. Final Answer:

    float -> Option C
  4. Quick Check:

    Explicit float mapping means price = float [OK]
Hint: Explicit mapping sets exact type, here float for price [OK]
Common Mistakes:
  • Assuming price becomes integer automatically
  • Thinking dynamic mapping applies here
  • Confusing float with text or keyword
4. You have this mapping snippet:
{"mappings": {"properties": {"date": {"type": "date"}}}}

After indexing a document with "date": "not-a-date", what error will occur?
medium
A. No error, field stored as text
B. Document rejected with parsing exception
C. Field ignored silently
D. Mapping conflict error due to wrong type

Solution

  1. Step 1: Check mapping type for date

    The field "date" is explicitly mapped as "date" type, so Elasticsearch expects a valid date format.
  2. Step 2: Indexing invalid date string

    Indexing "not-a-date" will cause a parsing exception because it cannot convert the string to a date.
  3. Final Answer:

    Document rejected with parsing exception -> Option B
  4. Quick Check:

    Invalid date string causes parsing error [OK]
Hint: Invalid date string causes parsing error, not silent ignore [OK]
Common Mistakes:
  • Thinking field stores as text automatically
  • Assuming no error occurs
  • Believing field is ignored silently
5. You want to prevent Elasticsearch from automatically adding new fields to your index but still allow existing fields to be indexed. Which mapping setting should you use?
hard
A. "dynamic": "strict"
B. "dynamic": "true"
C. "dynamic": "false"
D. "dynamic": "runtime"

Solution

  1. Step 1: Understand dynamic mapping options

    "dynamic": "true" allows new fields to be added automatically, "false" ignores new fields, "strict" rejects documents with unknown fields.
  2. Step 2: Choose setting to prevent new fields but allow existing

    "strict" rejects documents with new fields, so only existing fields are indexed, preventing unwanted additions.
  3. Final Answer:

    "dynamic": "strict" -> Option A
  4. Quick Check:

    Use strict to block new fields, allow existing [OK]
Hint: Use dynamic: strict to block new fields but keep existing [OK]
Common Mistakes:
  • Using dynamic: false which ignores new fields silently
  • Using dynamic: true which allows new fields
  • Confusing runtime with dynamic setting
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard