Bird
0
0

You want to store a nested object address with fields city and zipcode. How should you define the mapping to ensure Elasticsearch understands the nested structure?

hard🚀 Application Q8 of 15
Elasticsearch - Mappings and Data Types
You want to store a nested object address with fields city and zipcode. How should you define the mapping to ensure Elasticsearch understands the nested structure?
A"address": { "type": "text", "city": "text", "zipcode": "keyword" }
B"address": { "type": "object", "fields": { "city": "text", "zipcode": "keyword" } }
C"address": { "type": "nested", "properties": { "city": { "type": "text" }, "zipcode": { "type": "keyword" } } }
D"address": [ { "city": "text" }, { "zipcode": "keyword" } ]
Step-by-Step Solution
Solution:
  1. Step 1: Understand nested type usage

    Nested type allows storing arrays of objects with their own properties.
  2. Step 2: Identify correct syntax for nested mapping

    Use "type": "nested" and define "properties" for inner fields.
  3. Final Answer:

    "address": { "type": "nested", "properties": { "city": { "type": "text" }, "zipcode": { "type": "keyword" } } } -> Option C
  4. Quick Check:

    Nested objects use "type": "nested" with properties = C [OK]
Quick Trick: Use "nested" type with properties for nested objects [OK]
Common Mistakes:
MISTAKES
  • Using "fields" instead of "properties"
  • Defining nested fields as arrays or strings
  • Confusing nested with object type

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes