O'Reilly logo

Elasticsearch: A Complete Guide by Saurabh Chhajed, Marek Rogoziński, Rafał Kuć, Bharvi Dixit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with nested objects

Nested objects look similar to plain objects but they differ in mapping and the way they are stored internally in Elasticsearch.

We will work with the same Twitter data but this time we will index it in a nested structure. We will have a user as our root object and every user can have multiple tweets as nested documents. Indexing this kind of data without using nested mapping will lead to problems, as shown in the following example:

PUT /twitter/tweet/1 { "user": { "screen_name": "d_bharvi", "followers_count": "2000", "created_at": "2012-06-05" }, "tweets": [ { "id": "121223221", "text": "understanding nested relationships", "created_at": "2015-09-05" }, { "id": "121223222", "text": "NoSQL databases are awesome", "created_at": ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required