title: Elasticsearch Aggregation of large list
body: <p>I'm trying to count how many times ingredients show up in different documents. My index body is similar to this</p>
  <pre><code>index_body = {
     &quot;settings&quot;:{
        &quot;index&quot;:{
           &quot;number_of_replicas&quot;:0,
           &quot;number_of_shards&quot;:4,
           &quot;refresh_interval&quot;:&quot;-1&quot;,
           &quot;knn&quot;:&quot;true&quot;
        }
     },
     &quot;mappings&quot;:{
        &quot;properties&quot;:{
           &quot;recipe_id&quot;:{
              &quot;type&quot;:&quot;keyword&quot;
           },
           &quot;recipe_title&quot;:{
              &quot;type&quot;:&quot;text&quot;,
              &quot;analyzer&quot;:&quot;standard&quot;,
              &quot;similarity&quot;:&quot;BM25&quot;
           },
           &quot;description&quot;:{
               &quot;type&quot;:&quot;text&quot;,
               &quot;analyzer&quot;:&quot;standard&quot;,
               &quot;similarity&quot;:&quot;BM25&quot;
           },
           &quot;ingredient&quot;:{
              &quot;type&quot;:&quot;keyword&quot;
           },
           &quot;image&quot;:{
              &quot;type&quot;:&quot;keyword&quot;
           },
  
           ....
     }
  }
  </code></pre>
  <p>In the ingredient field, I've stored an array of strings of each ingredient <code>[ingredient1,ingredient2,....]</code></p>
  <p>I have around 900 documents. Each with their own ingredients list.</p>
  <p>I've tried using Elasticsearch's aggregations but it seems to not return what I expected.
  Here is the query I've been using:</p>
  <pre><code>{
          &quot;size&quot;:0,
          &quot;aggs&quot;:{
              &quot;ingredients&quot;:{
                  &quot;terms&quot;: {&quot;field&quot;:&quot;ingredient&quot;} 
              }
          }
      }
  </code></pre>
  <p>But it returns this:</p>
  <pre><code>{'took': 4, 'timed_out': False, '_shards': {'total': 4, 'successful': 4, 'skipped': 0, 'failed': 0}, 'hits': {'total': {'value': 994, 'relation': 'eq'}, 'max_score': None, 'hits': []}, 'aggregations': {'ingredients': {'doc_count_error_upper_bound': 56, 'sum_other_doc_count': 4709, 'buckets': [{'key': 'salt', 'doc_count': 631}, {'key': 'oil', 'doc_count': 320}, {'key': 'sugar', 'doc_count': 314}, {'key': 'egg', 'doc_count': 302}, {'key': 'butter', 'doc_count': 291}, {'key': 'flour', 'doc_count': 264}, {'key': 'garlic', 'doc_count': 220}, {'key': 'ground pepper', 'doc_count': 185}, {'key': 'vanilla extract', 'doc_count': 146}, {'key': 'lemon', 'doc_count': 131}]}}}
  </code></pre>
  <p>This is clearly wrong, as I have many ingredients. What am I doing wrong? Why is it returning only these ones? Is there a way to force Elasticsearch to return all counts?</p>