title: Is it possible to map/reduce a set of "ratings" into "relationships" in couchdb/cloudant?
body: <p>I have "ratings" documents that record the rating a user gave to a certain item, like this:</p>
  
  <pre><code>accountID: a1, itemID: i1, rating: 1
  accountID: a2, itemID: i1, rating: 1
  accountID: a3, itemID: i1, rating: 1
  accountID: a1, itemID: i2, rating: 1
  accountID: a2, itemID: i3, rating: 1
  </code></pre>
  
  <p>I would like to create a view that shows which users rated the same item, and how many times. Following the above data, we see that a1, a2 and a3 rated the same item i1, while i2 and i3 were only rated individually. The resulting set should then look like:</p>
  
  <pre><code>accountID1: a1, accountID2: a2, numMatches: 1
  accountID1: a1, accountID2: a3, numMatches: 1
  accountID1: a2, accountID2: a3, numMatches: 1
  </code></pre>
  
  <p>This shows that a1 and a2 both rated the same item once (i1), as did a1 and a3, and a2 and a3 (all for i1). The other items were ignored since only one user rated them.</p>
  
  <p>Is it possible to achieve this transformation with map/reduce in couchdb/cloudant? Or do I have to do the calculations client-side by pulling all ratings for a given item and running through every account?</p>