title: CouchDB returns "wrong" total_rows
body: <p>I have 5680 documents in my CouchDB.</p>
  
  <p>I reduced it with something like:</p>
  
  <pre><code>function(doc) {
    if (doc.address.country &amp;&amp; doc.cats) {
       for (i = 0; i &lt; doc.cats.length; i++) { 
         emit([doc.address.country, doc.cats[i].id], doc);
       }    
    }
  }
  </code></pre>
  
  <p>Running my view with: 
  myview?key=["CC","category"]</p>
  
  <p>Returns the expected result (25 items).</p>
  
  <p>However there is a field in the response:</p>
  
  <pre><code>{"total_rows":5680,"offset":5655, ...
  </code></pre>
  
  <p>The total_rows count is my full data set, not only the ones which matched my query. Is there a way to see the matching rows in the result?</p>
  
  <p>I would like to prevent duplicating the map code to just add a reduce function. In addition I would like to prevent two http requests just for that information.</p>
  
  <p>For me this information would be useful to implement something like pagination.</p>
  
  <p>I have read this: 
  <a href="http://docs.couchdb.org/en/1.6.1/couchapp/views/pagination.html" rel="nofollow">http://docs.couchdb.org/en/1.6.1/couchapp/views/pagination.html</a></p>
  
  <p>But they are not paginating over a limited subset of my data rows. </p>
  
  <p>As I found out, simply substracting offset from the total rows will not work (of course).</p>
  
  <p>How can I have a correct number of total_rows in my response, or what are the best practices in my use case?</p>
  
  <p>Thanks!</p>