title: MongoDB Property String Starts With Query And Set Group Id
body: <p>Data structure - <strong>one document</strong> in a big collection:</p>
  
  <pre><code>{
    OPERATINGSYSTEM: "Android 6.0"
  }
  </code></pre>
  
  <p>Issue: The operatingsystem can equal e.g. "Android 5.0", "Android 6.0", "Windows Phone", "Windows Phone 8.1"</p>
  
  <p>There is  no property which only contains the kind of operating system e.g. only <code>Android</code>.</p>
  
  <hr>
  
  <p>I need to get the count of windows phones, and android phones.</p>
  
  <p>My temporary solution:</p>
  
  <pre><code>db.getCollection('RB').find(
      {OPERATINGSYSTEM: {$regex: "^Android"}}
  ).count();
  </code></pre>
  
  <p>I'm doing that query replacing <code>"^Android"</code> by windows phone and so on which takes much time and needs to be done in parallel.</p>
  
  <p>Using the aggregation framework I though about this:</p>
  
  <pre><code>db.RB.aggregate(
  {$group: {_id: {OPERATINGSYSTEM:"$OPERATINGSYSTEM"}}},)
  </code></pre>
  
  <p>But using this I  get an entry for each operatingsystem version <code>Android 5.0</code>, <code>Android 6.0</code> etc...</p>
  
  <p>The solution I'm searching for should return data in this format:</p>
  
  <pre><code>{
    "Android": 50,
    "Windows Phone": 100
  }
  </code></pre>
  
  <p>How can this be done in a single query?</p>