Bird
0
0

Which of the following is the correct syntax to add highlighting for the field content in an Elasticsearch query?

easy📝 Syntax Q12 of 15
Elasticsearch - Search Results and Scoring
Which of the following is the correct syntax to add highlighting for the field content in an Elasticsearch query?
A"highlight": {"fields": {"content": {}}}
B"highlight": {"field": "content"}
C"highlight": {"content": {"fields": {}}}
D"highlight": {"fields": ["content"]}
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct highlight syntax

    The correct syntax uses "highlight" with "fields" as an object mapping field names to options, like {"content": {}}.
  2. Step 2: Check each option

    "highlight": {"fields": {"content": {}}} matches the correct structure. Options B, C, and D use incorrect keys or data types.
  3. Final Answer:

    "highlight": {"fields": {"content": {}}} -> Option A
  4. Quick Check:

    Highlight fields syntax = "highlight": {"fields": {"content": {}}} [OK]
Quick Trick: Use "highlight": {"fields": {"fieldname": {}}} [OK]
Common Mistakes:
MISTAKES
  • Using "field" instead of "fields"
  • Putting fields inside an array instead of object
  • Misplacing keys inside highlight

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes