Bird
Raised Fist0

Why does this runtime field script cause an error?

medium📝 Debug Q7 of Q15
Elasticsearch - Advanced Patterns
Why does this runtime field script cause an error?
{"runtime_mappings": {"status": {"type": "keyword", "script": {"source": "emit(doc['status'].value.toUpperCase)"}}}}
AField type keyword cannot use scripts
Bstatus field does not exist
Cemit cannot be used with strings
DtoUpperCase is missing parentheses
Step-by-Step Solution
Solution:
  1. Step 1: Review method usage in script

    toUpperCase is a method and requires parentheses to call it.
  2. Step 2: Identify missing parentheses

    Script uses toUpperCase without (), causing a syntax error.
  3. Final Answer:

    toUpperCase is missing parentheses -> Option D
  4. Quick Check:

    Method calls need parentheses = B [OK]
Quick Trick: Always add () when calling methods in scripts [OK]
Common Mistakes:
MISTAKES
  • Forgetting parentheses on method calls
  • Assuming keyword type disallows scripts
  • Thinking emit cannot output strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes