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"]anduser.last = ["Smith", "Jones"]matches "Alice Jones"!). nestedData 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).flattenedData Type: Treats an entire complex JSON object with arbitrary keys as indexed keyword fields without mapping explosion.