title: Combining multiple aggregations
body: <p>I'm an absolute newbie in Elasticsearch and trying to get my head around aggregations. I need to run an aggregation parallel to the existing one.
  This is the sample document page structure.</p>
  
  <pre><code>{
    "brand": {
      "list": [
        "Apple"
      ],
      "name": "Apple"
    },
    "title": {
      "list": [
        "Apple Macbook Pro 15 - Intel I7 3,10ghz (2tb|r560|touchid|space) 2017"
      ]
    },
    "category": {
      "l1": {
        "name": "Computers/Tablets &amp; Networking",
        "id": 58058
      },
      "l2": {
        "name": "Laptops &amp; Netbooks",
        "id": 175672
      },
      "l3": {
        "name": "Apple Laptops",
        "id": 111422
      },
      "l4": {},
      "l5": {},
      "l6": {}
    }
  }
  </code></pre>
  
  <p>and this is the existing query I'm running to get the aggregation of top 5 category names for a given title, which is working perfectly.</p>
  
  <pre><code>{
      "size": 0,
      "aggs":
      {
          "categoryId":
          {
              "filter":
              {
                  "bool":
                  {
                      "filter": [
                      {
                          "term":
                          {
                              "title.list": "phone"
                          }
                      }]
                  }
              },
              "aggs":
              {
                  "results":
                  {
                      "terms":
                      {
                          "field": "category.l2.id",
                          "size": 5
                      },
                      "aggs":
                      {
                          "categoryName":
                          {
                              "terms":
                              {
                                  "field": "category.l2.name.keyword",
                                  "size": 1
                              }
                          }
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>Next, I need to find top 5 brand names associated with title keyword search, sorted in descending order if possible.
  So i try this, but it is not working, also throwing an error.</p>
  
  <pre><code>{
      "size": 0,
      "aggs":
      {
          "categoryId":
          {
              "filter":
              {
                  "bool":
                  {
                      "filter": [
                      {
                          "term":
                          {
                              "title.list": "phone"
                          }
                      }]
                  }
              },
              "aggs":
              {
                  "results":
                  {
                      "terms":
                      {
                          "field": "category.l2.id",
                          "size": 5
                      },
                      "aggs":
                      {
                          "categoryName":
                          {
                              "terms":
                              {
                                  "field": "category.l2.name.keyword",
                                  "size": 1
                              }
                          }
                      }
                  },
                  "brands_names":
                  {
                      "terms":
                      {
                          "field": "brand.name",
                          "size": 10
                      },
                      "aggs":
                      {
                          "brand_top_hits":
                          {
                              "top_hits":
                              {
                                  "size": 1
                              }
                          }
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>I know I'm missing something obvious. Should I be using a value-count or top hits query for finding the top 5 brands? And How do I combine it with existing category query?</p>