title: Split a field for a aggregates
body: <p>I have an field with a variety of (multi word) category tags that I'm trying to figure out how to get aggregates for.  For any given document there may be one or more tags separated by <code>|</code> characters.</p>
  
  <p>I have the following mapping for my field:</p>
  
  <pre><code>"category": {
      "type": "keyword",
      "fields": {
        "raw" : {
          "type": "keyword",
          "index": "not_analyzed"
        }
      }
  }
  </code></pre>
  
  <p>This works for storing the data, but when I try to get the aggregates, for example:</p>
  
  <pre><code>{"aggregates": {
      "categories": {
          "terms": {
              "field": "category"
          }
      }
  }}
  </code></pre>
  
  <p>It returns whatever the field contains.  For example, if I have two documents with categories of</p>
  
  <ul>
  <li><code>Facilities|Information Technology</code></li>
  <li><code>Human Resources|Information Technology</code></li>
  </ul>
  
  <p>I'd like to get back something like:</p>
  
  <ul>
  <li><code>Information Technology: 2</code></li>
  <li><code>Facilities: 1</code></li>
  <li><code>Human Resources: 1</code></li>
  </ul>
  
  <p>Any suggestions on what I need to do to either split the data as part of my mapping or aggregates query?</p>