Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Elasticsearch Essentials

You're reading from   Elasticsearch Essentials Harness the power of ElasticSearch to build and manage scalable search and analytics solutions with this fast-paced guide

Arrow left icon
Product type Paperback
Published in Jan 2016
Publisher
ISBN-13 9781784391010
Length 240 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (12) Chapters Close

Preface 1. Getting Started with Elasticsearch FREE CHAPTER 2. Understanding Document Analysis and Creating Mappings 3. Putting Elasticsearch into Action 4. Aggregations for Analytics 5. Data Looks Better on Maps: Master Geo-Spatiality 6. Document Relationships in NoSQL World 7. Different Methods of Search and Bulk Operations 8. Controlling Relevancy 9. Cluster Scaling in Production Deployments 10. Backups and Security Index

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": "2015-06-05"
    }
  ]
}

PUT /twitter/tweet/2
{
  "user": {
    "screen_name": "d_bharvi",
    "followers_count": "2000",
    "created_at": "2012-06-05"
  },
  "tweets": [...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime