title: Aggregate by custom defined buckets, according to field value
body: <p>I'm interested in aggregating my data into buckets, but I want to put two distinct values to the same bucket.</p>
  <p>This is what I mean:</p>
  <p>Say I have this query:</p>
  <pre><code>GET _search
  {
    &quot;size&quot;: 0, 
    &quot;aggs&quot;: {
      &quot;my-agg-name&quot;: {
        &quot;terms&quot;: {
          &quot;field&quot;: &quot;ecs.version&quot;
        }
      }
    }
  }
  </code></pre>
  <p>it returns this response:</p>
  <pre><code>&quot;aggregations&quot; : {
      &quot;my-agg-name&quot; : {
        &quot;doc_count_error_upper_bound&quot; : 0,
        &quot;sum_other_doc_count&quot; : 0,
        &quot;buckets&quot; : [
          {
            &quot;key&quot; : &quot;1.12.0&quot;,
            &quot;doc_count&quot; : 642826144
          },
          {
            &quot;key&quot; : &quot;8.0.0&quot;,
            &quot;doc_count&quot; : 204064845
          },
          {
            &quot;key&quot; : &quot;1.1.0&quot;,
            &quot;doc_count&quot; : 16508253
          },
          {
            &quot;key&quot; : &quot;1.0.0&quot;,
            &quot;doc_count&quot; : 9162928
          },
          {
            &quot;key&quot; : &quot;1.6.0&quot;,
            &quot;doc_count&quot; : 1111542
          },
          {
            &quot;key&quot; : &quot;1.5.0&quot;,
            &quot;doc_count&quot; : 10445
          }
        ]
      }
    }
  </code></pre>
  <p>every distinct value of the field <code>ecs.version</code> is in it's own bucket.</p>
  <p>But say I wanted to define my buckets such that:
  bucket1: [1.12.0, 8.0.0]
  bucket2: [1.6.0, 8.4.0]
  bucket3: [1.0.0, 8.8.0]</p>
  <p>Is this possible in anyway?</p>
  <p>I know I can just return all the buckets and do the sum programmatically, but this list can be very long, I don't think it would be efficient. Am I wrong?</p>