title: Why is my multiple-key GET query to Cloudant returning all documents?
body: <p>Just starting out. </p>
  
  <p>I have a view on cloudant, bywords, that provides a view of all documents and their keywords.  It looks like this: </p>
  
  <pre><code>bywords = function(doc) {
      var tokens, re1,
          uniq = function(a) {
              var o = {}, i = 0, L = a.length, r = [];
              for (; i &lt; L; i++) {
                  if (a[i] !== '' &amp;&amp; a[i] !== ' ') {
                      o[a[i]] = a[i];
                  }
              }
              for (i in o) { r.push(o[i]); }
              return r;
          };
  
      if ( doc.observation &amp;&amp; doc.observation !== '') {
          tokens = uniq(doc.observation.split(/( +)|\./));
          if (tokens &amp;&amp; tokens.length &gt; 0) {
               tokens.map(function(token) {
                   emit(token, null);
               });
           }
      }
  };
  </code></pre>
  
  <p>(I don't think there is a <code>unique</code> fn available to me in the design doc, so that view fn defines its own.)</p>
  
  <p>The result of the view looks like this: </p>
  
  <pre><code>....
  {
   "id": "doc-095141",
   "key": "Vivamus",
   "value": null
  },
  {
   "id": "doc-102754",
   "key": "Vivamus",
   "value": null
  },
  {
   "id": "doc-094047",
   "key": "volutpat",
   "value": null
  },
  {
   "id": "doc-092332",
   "key": "vulputate",
   "value": null
  },
  ....
  </code></pre>
  
  <p>There's one item in the view, for every word in a particular field of the document, for each document. </p>
  
  <p>ok...</p>
  
  <p>Querying by key works nicely. I mean, this:</p>
  
  <p><code>https://myserver.cloudant.com/fop/_design/baseViews/_view/bywords?key=%22amet%22</code> </p>
  
  <p>...returns the expected subset of items from the view.  It's a handful of items, fewer than 10. </p>
  
  <p>On the other hand a multi-key query returns all items in the view. If I do this: </p>
  
  <p><code>https://.../_design/baseViews/_view/bywords?keys=%5B%22amet%22%5D</code> </p>
  
  <p>...then I get every item.  Many many items. Not what I want. </p>
  
  <p><strong>How can I specify multiple keys in a GET?</strong> </p>
  
  <p>I don't believe I want <code>startkey</code> and <code>endkey</code>.  I want the items with keys present in the set I specify. </p>
  
  <hr>
  
  <p>ps: I know about <a href="http://wiki.apache.org/couchdb/HTTP_view_API#Access.2BAC8-Query" rel="nofollow">the option to POST a JSON keys array</a>.  I haven't tried that yet.  From my reading the doc, I should be able to do a GET and specify multiple keys in the query string. </p>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>I just tried the POST option.  It works as expected. In other words, this HTTP request:</p>
  
  <pre><code>POST https://myserver.cloudant.com/fop/_design/baseViews/_view/bywords 
  ...headers here...
  
  {"keys":["amet"]}
  </code></pre>
  
  <p>..returns what I expected it to return: a handful of matching documents.  </p>
  
  <p>So, I am no longer blocked, but it remains a puzzle to me that the GET / URI-encoded form for specifying keys does not work on Cloudant. </p>