Bird
0
0

Which of the following JSON snippets correctly returns only the title and author fields in the search results using source filtering?

easy📝 Syntax Q3 of 15
Elasticsearch - Search Results and Scoring
Which of the following JSON snippets correctly returns only the title and author fields in the search results using source filtering?
A{"_source": {"includes": ["title", "author"]}, "query": {"match_all": {}}}
B{"_source": {"excludes": ["title", "author"]}, "query": {"match_all": {}}}
C{"_source": ["title", "author"], "query": {"match_all": {}}}
D{"_source": false, "query": {"match_all": {}}}
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct syntax

    To include specific fields, use _source.includes with an array of field names.
  2. Step 2: Analyze options

    {"_source": {"includes": ["title", "author"]}, "query": {"match_all": {}}} correctly uses includes with an array. {"_source": {"excludes": ["title", "author"]}, "query": {"match_all": {}}} excludes fields, {"_source": ["title", "author"], "query": {"match_all": {}}} uses an invalid format, and {"_source": false, "query": {"match_all": {}}} disables source entirely.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Includes array returns only specified fields [OK]
Quick Trick: Use _source.includes with array for specific fields [OK]
Common Mistakes:
MISTAKES
  • Using excludes instead of includes to select fields
  • Passing a string instead of an array
  • Setting _source to false disables all fields

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes