title: elasticsearch aggregation using a script to transform field value being aggregated
body: <p>I currently have something like:</p>
  
  <pre><code>"aggs": {
          "group_by_myfield": {
              "terms": {
                  "field": "myfield"
              }
          }
      }
  </code></pre>
  
  <p>However the value for myfield is "alpha 1.0", "alpha 2.0", "beta 1.0". Now I want to only aggregate over the values "alpha", "beta". How do I do that? I tried: </p>
  
  <pre><code>"aggs": {
          "group_by_myfield": {
              "terms": {
                  "field": "myfield"
                  "script": "_value.split()[0]"
              }
          }
      }
  </code></pre>
  
  <p>But I guess there is no split functionality. Any suggestions are welcome!</p>
  
  <p>I found a similar question <a href="https://stackoverflow.com/questions/23067983/term-aggregation-consider-only-the-prefix-to-aggregate">here</a> which is unanswered as well.</p>