Bird
0
0

Which of the following JSON snippets correctly represents a match_phrase query searching for the phrase "machine learning" in the field "title"?

easy📝 Syntax Q3 of 15
Elasticsearch - Basic Search Queries
Which of the following JSON snippets correctly represents a match_phrase query searching for the phrase "machine learning" in the field "title"?
A{ "query": { "match_phrase": { "title": "machine learning" } } }
B{ "query": { "match": { "title": "machine learning" } } }
C{ "query": { "match_phrase": { "title": ["machine", "learning"] } } }
D{ "query": { "match_phrase": "machine learning" } }
Step-by-Step Solution
Solution:
  1. Step 1: Identify the correct structure

    The match_phrase query requires a field name with a string value representing the phrase.
  2. Step 2: Evaluate each option

    { "query": { "match_phrase": { "title": "machine learning" } } } correctly uses the field "title" with the phrase as a string. { "query": { "match": { "title": "machine learning" } } } uses match instead of match_phrase. { "query": { "match_phrase": { "title": ["machine", "learning"] } } } incorrectly uses an array instead of a string. { "query": { "match_phrase": "machine learning" } } omits the field name.
  3. Final Answer:

    { "query": { "match_phrase": { "title": "machine learning" } } } -> Option A
  4. Quick Check:

    Correct syntax requires field name and phrase string [OK]
Quick Trick: Use field name with phrase string in match_phrase [OK]
Common Mistakes:
MISTAKES
  • Using an array instead of a string for the phrase
  • Omitting the field name
  • Confusing match with match_phrase

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes