Bird
0
0

Given this mapping snippet:

medium📝 Predict Output Q4 of 15
Elasticsearch - Mappings and Data Types
Given this mapping snippet:
{"properties": {"tags": {"type": "nested"}}}

Which query will correctly find documents with a tag named "urgent"?
A{"nested": {"path": "tags", "query": {"match": {"tags.name": "urgent"}}}}
B{"match": {"tags.name": "urgent"}}
C{"term": {"tags": "urgent"}}
D{"nested": {"path": "tags", "query": {"term": {"name": "urgent"}}}}
Step-by-Step Solution
Solution:
  1. Step 1: Understand nested query structure

    To query nested fields, use a nested query with the correct path and field name inside the query.
  2. Step 2: Analyze options

    {"nested": {"path": "tags", "query": {"match": {"tags.name": "urgent"}}}} uses nested query with path "tags" and matches "tags.name" correctly. {"match": {"tags.name": "urgent"}} lacks nested wrapper, C uses term on wrong field, D uses term on "name" without path prefix.
  3. Final Answer:

    Option A correctly queries nested tags by name -> Option A
  4. Quick Check:

    Nested query requires path and full field name [OK]
Quick Trick: Use nested query with path and full field name for nested fields [OK]
Common Mistakes:
MISTAKES
  • Omitting nested query wrapper
  • Using term query on nested object directly
  • Incorrect field path in query

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes