title: How to do basic aggregation with DynamoDB?
body: <p>How is aggregation achieved with dynamodb? Mongodb and couchbase have map reduce support.</p>
  
  <p>Lets say we are building a tech blog where users can post articles. And say articles can be tagged.</p>
  
  <pre><code>user
  {
      id : 1235,
      name : "John",
      ...
  }
  
  article
  {
      id : 789,
      title: "dynamodb use cases",
      author : 12345 //userid
      tags : ["dynamodb","aws","nosql","document database"]
  }
  </code></pre>
  
  <p>In the user interface we want to show for the current user tags and the respective count.</p>
  
  <p>How to achieve the following aggregation?</p>
  
  <pre><code>{
      userid : 12,
      tag_stats:{
          "dynamodb" : 3,
          "nosql" : 8
      }
  }
  </code></pre>
  
  <p>We will provide this data through a rest api and it will be frequently called. Like this information is shown in the app main page. </p>
  
  <ul>
  <li>I can think of extracting all documents and doing aggregation at the application level. But I feel my read capacity units will be exhausted </li>
  <li>Can use tools like EMR, redshift, bigquery, aws lambda. But I think these are for datawarehousing purpose.</li>
  </ul>
  
  <p>I would like to know other and better ways of achieving the same.
  How are people achieving dynamic simple queries like these having chosen dynamodb as primary data store considering cost and response time.</p>