title: Elasticsearch: Aggregate results of query
body: <p>I have an elasticsearch index containing products, which I can query for different search terms. Every product contains a field <code>shop_id</code> to reference the shop it belongs to. Now I try to display a list of all shops holding products for my query. (To filter by shops)
  As far as I read on similar questions, I have to use an aggregation. Finally I built this query:</p>
  
  <pre><code>curl -XGET 'http://localhost:9200/searchindex/_search?search_type=count&amp;pretty=true' -d '{
    "query" : {
        "match" : {
            "_all" : "playstation"
        }
    },
    "aggregations": {
      "shops_count": {
        "terms": {
          "field": "shop_id"
        }
      }
    }
  }'
  </code></pre>
  
  <p>This should search for <code>playstation</code> and aggregate the results based on <code>shop_id</code>. Sadly it only returns </p>
  
  <blockquote>
    <p>Data too large, data would be larger than limit of [8534150348]
    bytes].</p>
  </blockquote>
  
  <p>I also tried it with queries returning only 2 results.
  The index contains more than 90,000,000 products.</p>