Bird
0
0

You want to find documents where the phrase "system failure" appears, but you want to allow up to two words between "system" and "failure". Which match_phrase query option should you use?

hard🚀 Application Q8 of 15
Elasticsearch - Basic Search Queries
You want to find documents where the phrase "system failure" appears, but you want to allow up to two words between "system" and "failure". Which match_phrase query option should you use?
A{ "query": { "match_phrase": { "message": "system failure" } } }
B{ "query": { "match_phrase": { "message": { "query": "system failure", "slop": 2 } } } }
C{ "query": { "match": { "message": { "query": "system failure", "slop": 2 } } } }
D{ "query": { "match_phrase": { "message": { "query": "system failure", "fuzziness": 2 } } } }
Step-by-Step Solution
Solution:
  1. Step 1: Understand slop parameter

    The slop option in match_phrase allows a specified number of words between the phrase terms.
  2. Step 2: Evaluate options

    { "query": { "match_phrase": { "message": { "query": "system failure", "slop": 2 } } } } correctly uses slop": 2 to allow two words between "system" and "failure". { "query": { "match_phrase": { "message": "system failure" } } } does not allow any gaps. { "query": { "match": { "message": { "query": "system failure", "slop": 2 } } } } incorrectly uses match instead of match_phrase. { "query": { "match_phrase": { "message": { "query": "system failure", "fuzziness": 2 } } } } incorrectly uses fuzziness which is unrelated to phrase gaps.
  3. Final Answer:

    { "query": { "match_phrase": { "message": { "query": "system failure", "slop": 2 } } } } -> Option B
  4. Quick Check:

    Use slop to allow gaps in match_phrase [OK]
Quick Trick: Use slop to allow word gaps in match_phrase [OK]
Common Mistakes:
MISTAKES
  • Using fuzziness instead of slop
  • Applying slop to match query
  • Not specifying slop for phrase gaps

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes