0
0
Elasticsearchquery~20 mins

Numeric field types in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Numeric Field Types Master
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 for a numeric field?
Given this Elasticsearch mapping snippet, what is the type of the field age and what is its default behavior?
Elasticsearch
{
  "mappings": {
    "properties": {
      "age": {
        "type": "integer"
      }
    }
  }
}
AThe field <code>age</code> is a 32-bit signed integer and supports range queries.
BThe field <code>age</code> is a floating-point number and supports decimal values.
CThe field <code>age</code> is a string and does not support numeric operations.
DThe field <code>age</code> is a 64-bit unsigned integer.
Attempts:
2 left
💡 Hint
Think about the standard integer type in Elasticsearch and what it supports.
Predict Output
intermediate
2:00remaining
What happens when you index a decimal number into a field of type long?
Consider this mapping and document indexing: Mapping: { "mappings": { "properties": { "price": { "type": "long" } } } } Document: { "price": 19.99 } What will Elasticsearch do?
AIt will round the decimal 19.99 to 20 and store it as a long integer.
BIt will store the decimal 19.99 exactly as a long integer without rounding.
CIt will convert the decimal to a string and store it as text.
DIt will reject the document and throw a mapping exception error.
Attempts:
2 left
💡 Hint
Think about how Elasticsearch handles decimal values for integer types.
🔧 Debug
advanced
2:00remaining
Why does this mapping cause an error?
This mapping snippet causes an error when applied. Identify the cause: { "mappings": { "properties": { "score": { "type": "unsigned_long" } } } }
AThe field name <code>score</code> is a reserved keyword and cannot be used.
BElasticsearch does not support the <code>unsigned_long</code> type; only <code>long</code> is valid.
CThe mapping is missing the <code>index</code> property which is required for numeric fields.
DThe <code>unsigned_long</code> type requires a <code>coerce</code> property to be set.
Attempts:
2 left
💡 Hint
Check the official Elasticsearch numeric types supported.
📝 Syntax
advanced
2:00remaining
Which mapping snippet correctly defines a scaled_float field with a scaling factor of 100?
Choose the correct Elasticsearch mapping for a scaled_float field named rating with a scaling factor of 100.
A{ "mappings": { "properties": { "rating": { "type": "float", "scaling_factor": 100 } } } }
B{ "mappings": { "properties": { "rating": { "type": "scaled_float", "scale_factor": 100 } } } }
C{ "mappings": { "properties": { "rating": { "type": "scaled_float", "scaling_factor": 100 } } } }
D{ "mappings": { "properties": { "rating": { "type": "scaled_float", "scaling": 100 } } } }
Attempts:
2 left
💡 Hint
Check the exact property name for scaling factor in the official docs.
🚀 Application
expert
2:00remaining
How many numeric fields are created by this mapping?
Given this Elasticsearch mapping, how many numeric fields are defined? { "mappings": { "properties": { "id": { "type": "keyword" }, "count": { "type": "integer" }, "price": { "type": "scaled_float", "scaling_factor": 100 }, "rating": { "type": "float" }, "timestamp": { "type": "date" } } } }
A3
B2
C5
D4
Attempts:
2 left
💡 Hint
Count only fields with numeric types like integer, float, scaled_float.