Bird
Raised Fist0

What will be the output of this runtime field script?

medium📝 Predict Output Q5 of Q15
Elasticsearch - Advanced Patterns
What will be the output of this runtime field script?
{"runtime_mappings": {"double_price": {"type": "double", "script": {"source": "emit(doc['price'].value * 2)"}}}}

For a document with price 15.5?
A15.5
B31.0
C30
DError: type mismatch
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the script calculation

    The script multiplies the price field value by 2 and emits the result as a double.
  2. Step 2: Calculate for price 15.5

    15.5 * 2 = 31.0, which matches the double type output.
  3. Final Answer:

    31.0 -> Option B
  4. Quick Check:

    Price 15.5 doubled = 31.0 [OK]
Quick Trick: Multiply numeric fields and emit result as double for decimals [OK]
Common Mistakes:
MISTAKES
  • Confusing integer 30 with double 31.0
  • Expecting original price instead of doubled
  • Assuming type mismatch error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes