title: elasticsearch aggregation - why is a match all query not returning keys that a more specific query is?
body: <p>I am doing some aggregations. But the results are not at all what I expect, it seems that they are not aggregating over all the documents matching my query in the index, in which case - what good is it? </p>
  
  <p>As an example, First I do this query:</p>
  
  <pre><code>{"index":"datalayer","type":"analysis2","body":{"query":{
          "match_all" : {}
      },
      "aggs" : {
          "objects" : {
              "terms" : {
                "field" : "action"
              }
          }
      }
  }}
  </code></pre>
  
  <p>and the result is 500 hits with aggregations as follows:</p>
  
  <pre><code>"aggregations": {
      "objects": {
          "buckets": [
              {
                  "key": "thing",
                  "doc_count": 278
              },
              {
                  "key": "hover",
                  "doc_count": 273
              },
              {
                  "key": "embedded",
                  "doc_count": 57
              },
              {
                  "key": "view",
                  "doc_count": 50
              },
              {
                  "key": "widgets",
                  "doc_count": 49
              },
              {
                  "key": "hovered",
                  "doc_count": 20
              },
              {
                  "key": "widgetembed",
                  "doc_count": 20
              },
              {
                  "key": "products",
                  "doc_count": 19
              },
              {
                  "key": "create",
                  "doc_count": 15
              },
              {
                  "key": "image",
                  "doc_count": 13
              }
          ]
      }
  }
  </code></pre>
  
  <p>that's all well and good but I know I have some where the key should be activation. 
  So if I then do the query </p>
  
  <pre><code>{"index":"datalayer","type":"analysis2","body":{"query":{
          "bool": {
          "must" : [
              {"match": {"object": "Widget"}}
          ]
      }},
      "aggs" : {
          "objects" : {
              "terms" : {
                "field" : "action"
              }
          }
      }
  }}
  </code></pre>
  
  <p>then the result is 45 hits with aggregations</p>
  
  <pre><code>"aggregations": {
          "objects": {
              "buckets": [
                  {
                      "key": "widgets",
                      "doc_count": 41
                  },
                  {
                      "key": "embedded",
                      "doc_count": 40
                  },
                  {
                      "key": "view",
                      "doc_count": 32
                  },
                  {
                      "key": "activation",
                      "doc_count": 9
                  },
                  {
                      "key": "image",
                      "doc_count": 4
                  },
                  {
                      "key": "create",
                      "doc_count": 3
                  },
                  {
                      "key": "mapping",
                      "doc_count": 3
                  },
                  {
                      "key": "widget",
                      "doc_count": 3
                  },
                  {
                      "key": "adding",
                      "doc_count": 2
                  },
                  {
                      "key": "edit",
                      "doc_count": 1
                  }
              ]
          }
      }
  </code></pre>
  
  <p>as can be seen in these aggregations I have a some keys that are not in my first aggregation of actions matching all documents. Why is that? And what do I have to do to get a bucket with all documents actions in it.</p>
  
  <p>I don't think it can just be that I need to do pagination or something because I have also tried to do </p>
  
  <pre><code>{"index":"datalayer","type":"analysis2","body":{"from":0,"size":500,"query":{
          "match_all" : {}
      },
      "aggs" : {
          "objects" : {
              "terms" : {
                "field" : "action"
              }
          }
      }
  }}
  </code></pre>
  
  <p>with the exact same aggregation result of </p>
  
  <pre><code>"aggregations": {
      "objects": {
          "buckets": [
              {
                  "key": "thing",
                  "doc_count": 278
              },
              {
                  "key": "hover",
                  "doc_count": 273
              },
              {
                  "key": "embedded",
                  "doc_count": 57
              },
              {
                  "key": "view",
                  "doc_count": 50
              },
              {
                  "key": "widgets",
                  "doc_count": 49
              },
              {
                  "key": "hovered",
                  "doc_count": 20
              },
              {
                  "key": "widgetembed",
                  "doc_count": 20
              },
              {
                  "key": "products",
                  "doc_count": 19
              },
              {
                  "key": "create",
                  "doc_count": 15
              },
              {
                  "key": "image",
                  "doc_count": 13
              }
          ]
      }
  }
  </code></pre>
  
  <p>So, I'm hoping someone can explain to me why the I am not seeing the keys in the buckets that I am expecting here? </p>