Skip to main content
InterviewHubPRO
Section Overview
Q18

Question 18 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

36%
Elasticsearch & Lucene (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

What is the difference between `nested` objects and `flattened` objects?

senior LevelSystem Design

In Simple Words:

  • Standard Object Array: Elasticsearch flattens arrays of objects, losing individual object boundaries (e.g. user.first = ["Alice", "Bob"] and user.last = ["Smith", "Jones"] matches "Alice Jones"!).
  • nested Data Type: Indexes each array item as a hidden separate Lucene document, preserving object boundaries for precise multi-field queries (at the cost of slower indexing).
  • flattened Data Type: Treats an entire complex JSON object with arbitrary keys as indexed keyword fields without mapping explosion.