title: Elasticsearch - use terms bucket key as filter variable
body: <p>I index these:</p>
  
  <pre><code>POST nephi/boat/1
  {
      "plates": {
          "id": 123,
          "type": "brass"
      },
      "compass": {
          "id": 123,
          "name": "liahona"
      }
  }
  
  POST nephi/boat/2
  {
      "plates": {
          "id": 100,
          "type": "brass"
      },
      "compass": {
          "id": 234,
          "name": "liahona"
      }
  }
  </code></pre>
  
  <p>I use this search query so I can do an aggregation where <code>plates.id</code> and <code>compass.id</code> are equal:</p>
  
  <pre><code>POST nephi/boat/_search
  {
     "aggs": {
        "terms_agg": {
           "terms": {
              "field": "plates.id"
           },
           "aggs": {
              "filter_agg": {
                 "filter": {
                    "term": {
                       "compass.id": 123
                    }
                 }
              }
           }
        }
     },
     "size": 0
  }
  </code></pre>
  
  <p>Rather than using <code>"compass:id": 123</code>, I'd like to be able to use a variable in place of 123, like <code>"compass:id": "__bucket_key"</code>, where <code>__bucket_key</code> would reference 123 on the first doc above, and 100 on the second doc above (the <code>plates.id</code>s).  </p>
  
  <p>Is something like this possible?</p>