0
0
Elasticsearchquery~10 mins

Dynamic templates in Elasticsearch - Interactive Code Practice

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

Complete the code to define a dynamic template that matches all string fields.

Elasticsearch
{
  "mappings": {
    "dynamic_templates": [
      {
        "strings_as_keywords": {
          "match_mapping_type": "[1]",
          "mapping": {
            "type": "keyword"
          }
        }
      }
    ]
  }
}
Drag options to blanks, or click blank then click option'
Astring
Btext
Ckeyword
Ddate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'text' instead of 'string' for match_mapping_type.
Using 'keyword' which is a field type, not a match_mapping_type.
2fill in blank
medium

Complete the code to apply a dynamic template only to fields matching the pattern 'user_*'.

Elasticsearch
{
  "mappings": {
    "dynamic_templates": [
      {
        "user_fields": {
          "match": "[1]",
          "mapping": {
            "type": "text"
          }
        }
      }
    ]
  }
}
Drag options to blanks, or click blank then click option'
Auser
Buser.*
Cuser_*
Duser?
Attempts:
3 left
💡 Hint
Common Mistakes
Using '?' which matches a single character.
Using 'user' without wildcard, which matches only exact field name.
3fill in blank
hard

Fix the error in the dynamic template to set the type to 'date' for fields matching 'date_*'.

Elasticsearch
{
  "mappings": {
    "dynamic_templates": [
      {
        "dates": {
          "match": "date_*",
          "mapping": {
            "type": "[1]"
          }
        }
      }
    ]
  }
}
Drag options to blanks, or click blank then click option'
Adatetime
Btime
Ctimestamp
Ddate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'datetime' or 'timestamp' which are not valid Elasticsearch types.
Using 'time' which is not a valid field type.
4fill in blank
hard

Fill both blanks to create a dynamic template that maps all numeric fields to type 'long' and disables indexing.

Elasticsearch
{
  "mappings": {
    "dynamic_templates": [
      {
        "long_numbers": {
          "match_mapping_type": "[1]",
          "mapping": {
            "type": "[2]",
            "index": false
          }
        }
      }
    ]
  }
}
Drag options to blanks, or click blank then click option'
Along
Binteger
Dfloat
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'integer' or 'float' instead of 'long' for long numbers.
Forgetting to disable indexing.
5fill in blank
hard

Fill all three blanks to create a dynamic template that matches fields ending with '_txt', maps them as 'text' type with 'english' analyzer, and disables norms.

Elasticsearch
{
  "mappings": {
    "dynamic_templates": [
      {
        "text_fields": {
          "match": "[1]",
          "mapping": {
            "type": "[2]",
            "analyzer": "[3]",
            "norms": false
          }
        }
      }
    ]
  }
}
Drag options to blanks, or click blank then click option'
A*_txt
Btext
Cenglish
Dkeyword
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'keyword' type instead of 'text'.
Using wrong match pattern without wildcard.