0
0
Elasticsearchquery~10 mins

Date field types 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 date field in Elasticsearch mapping.

Elasticsearch
{
  "mappings": {
    "properties": {
      "created_at": { "type": "[1]" }
    }
  }
}
Drag options to blanks, or click blank then click option'
Akeyword
Bdate
Ctext
Dinteger
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'text' or 'keyword' instead of 'date' for date fields.
2fill in blank
medium

Complete the code to specify a custom date format in the mapping.

Elasticsearch
{
  "mappings": {
    "properties": {
      "event_date": {
        "type": "date",
        "format": "[1]"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Akeyword
Btext
Cyyyy-MM-dd HH:mm:ss
Dinteger
Attempts:
3 left
💡 Hint
Common Mistakes
Using data types like 'integer' or 'text' as the format value.
3fill in blank
hard

Fix the error in the date format specification.

Elasticsearch
{
  "mappings": {
    "properties": {
      "publish_date": {
        "type": "date",
        "format": "[1]"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ayyyy/MM/dd HH:mm:ss
Byyyy-MM-dd HH:mm:ssZ
Cyyyy-MM-dd HH:mm:ss
Dyyyy-MM-dd'T'HH:mm:ssZ
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the 'T' separator or timezone indicator in the format.
4fill in blank
hard

Fill both blanks to create a mapping with a date field that accepts multiple formats.

Elasticsearch
{
  "mappings": {
    "properties": {
      "start_date": {
        "type": "date",
        "format": "[1]||[2]"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ayyyy-MM-dd
Bepoch_millis
Ctext
Dinteger
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid formats like 'text' or 'integer' as date formats.
5fill in blank
hard

Fill all three blanks to define a date field with a custom format, ignore malformed dates, and store dates as long.

Elasticsearch
{
  "mappings": {
    "properties": {
      "log_date": {
        "type": "date",
        "format": "[1]",
        "ignore_malformed": [2],
        "store": [3]
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ayyyy-MM-dd HH:mm:ss
Btrue
Cfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings instead of booleans for ignore_malformed or store.
Incorrect date format strings.