The "fields" key must be an object mapping field names to options, not an array.
Step 2: Verify other parts
"match" query is valid, "highlight" is correctly placed, and any field can be highlighted if indexed.
Final Answer:
"fields" should be an object, not an array -> Option B
Quick Check:
Highlight fields = object, not array [OK]
Hint: Highlight fields must be an object, not a list [OK]
Common Mistakes:
Using array instead of object for fields
Placing highlight inside query incorrectly
Assuming some fields can't be highlighted
5. You want to highlight matched text in both title and content fields with custom tags <strong> and </strong>. Which is the correct highlight section to achieve this?
D. "highlight": {"fields": {"title": {}, "content": {}}, "tags": ["", ""]}
Solution
Step 1: Understand how to set custom tags
Custom tags are set globally using "pre_tags" and "post_tags" arrays outside the fields object.
Step 2: Check each option's structure
"highlight": {"fields": {"title": {}, "content": {}}, "pre_tags": [""], "post_tags": [""]} correctly sets "fields" as an object and uses "pre_tags" and "post_tags" arrays. Options B, C, and D misuse keys or data types.