title: Elasticsearch filter aggregations on minimal doc count
body: <p>I am really new to elasticsearch world.</p>
  
  <p>Let's say I have a nested aggregation on two fields : <code>field1</code> and <code>field2</code> : </p>
  
  <pre><code>{
      ...
      aggs: {
          field1: {
              terms: {
                  field: 'field1'
              },
              aggs: {
                  field2: {
                      terms: {
                          field: 'field2'
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>This piece of code works perfectly and gives me something like this :</p>
  
  <pre><code>aggregations: {
      field1: {
          buckets: [{
              key: "foo",
              doc_count: 123456,
              field2: {
                  buckets: [{
                      key: "bar",
                      doc_count: 34323
                  },{
                      key: "baz",
                      doc_count: 10
                  },{
                      key: "foobar",
                      doc_count: 36785
                  },
                  ...
                  ]
          },{
              key: "fooOO",
              doc_count: 423424,
              field2: {
                  buckets: [{
                      key: "bar",
                      doc_count: 35
                  },{
                      key: "baz",
                      doc_count: 2435453
                  },
                  ...
                  ]
          },
          ...
          ]
      }
  }
  </code></pre>
  
  <p>Now, my need is to exclude all aggregation results where <code>doc_count</code> is less than 1000 for instance and get this instead :</p>
  
  <pre><code>aggregations: {
      field1: {
          buckets: [{
              key: "foo",
              doc_count: 123456,
              field2: {
                  buckets: [{
                      key: "bar",
                      doc_count: 34323
                  },{
                      key: "foobar",
                      doc_count: 36785
                  },
                  ...
                  ]
          },{
              key: "fooOO",
              doc_count: 423424,
              field2: {
                  buckets: [{
                      key: "baz",
                      doc_count: 2435453
                  },
                  ...
                  ]
          },
          ...
          ]
      }
  }
  </code></pre>
  
  <p>Is it possible to set this need in the query body ? or do I have to perform the filter in the caller layout (in javascript in my case)?</p>
  
  <p>Thanks in advance</p>