title: Elastic Search Query with filter and aggregation returns no aggregations
body: <p>I'm using the node.js sdk to run an elasticsearch query that searches all fields for some text, then filters the results to a subset, then aggregates based on a custom index. </p>
  
  <p>I've looked at the es documentation and several stack overflow questions that involve filters and aggregations to ensure my query syntax is correct, and I do not see a syntax error when the query is run. My query hits 2000+ documents in my dataset, but the response object contains no aggregations.</p>
  
  <pre><code>var search_text = "Chase Bank";
  var doctype_selections = ["mortgage"]; 
  
  es.search({
      index: index_list,
      type: 'page',
      body: {
          query: {
              filtered: {
                  query: {
                      match: {
                          _all: {
                              "query": search_text,
                              "operator": "and"
                          }
                      },
                      filter: {
                          terms: {
                              document_type: doctype_selections
                          }
                      }
                  }
              }
          },
          aggs: {
              "top_tag_hits":{
                  terms: {
                      field: "agg_index",
                      size: agg_size
                  },
                  aggs: {
                      "hits":{
                          top_hits: {
                              size: agg_size
                          }
                      }
                  }
              }
          },
      },
      explain: true,
      size: result_size, 
  }).then(function (resp) {
      var hits = resp.hits.hits;
      var aggs = resp.aggregations;
      console.log(resp);
      response.send(aggs);
  }, function (err) {
      console.trace(err.message);
      response.send(err.message);
  });
  </code></pre>
  
  <p>From what I understand the correct order of operations in es would be <code>query-&gt;filter query-&gt;aggregation on filtered query</code>. If remove the filter and the aggregation the query by itself works as intended. If I remove the filter, but keep the aggregation and the query it works and returns aggregations. If I remove the aggregation and keep the filter, it also works as intended.</p>
  
  <p>It seems as though the whole aggregation portion of the query is simply being ignored. What's the issue?</p>