title: CouchDB View Multiple key-value pairs
body: <p>I'm new to CouchDB and want to specify a year-range for a set of documents. Each document has a year attribute. I have defined my view as follows:</p>
  
  <pre><code>function(doc) {
      emit(parseInt(doc.year), doc.title);
  }
  </code></pre>
  
  <p>I then want to select movies made between (for example) 2000 and 2005. As far as I can understand, the following curl command should work for this.</p>
  
  <p><code>curl http://127.0.0.1:5984/movies/_design/exercises/_view/ex11?startkey=2000&amp;endkey=2005</code></p>
  
  <p>However, when I execute this command, only the first key-value pair seems to take effect (i.e. it only selects movies from after 2000). If I interchange the order of startkey and endkey pairs this is also the case (i.e. it only selects movies from before 2005)</p>
  
  <p>Furthermore, when I execute the curl command above, it seems the program does not terminate in the terminal. I have to manually terminate the query using CTRL+C, which doesn't happen with any other type of query.</p>
  
  <p>Each movie has the following JSON structure (for your reference):</p>
  
  <pre><code>{
     "_id": "uf",
     "_rev": "1-576d70babcd04fed2918f5c543bb7cf6",
     "title": "Unforgiven",
     "year": "1992",
     "genre": "Western",
     "summary": "The town of Big Whisky is full of normal people trying to lead quiet lives. Cowboys try to make a living. Sheriff 'Little Bill' tries to build a house and keep a heavy-handed order. The town whores just try to get by.Then a couple of cowboys cut up a whore. Unsatisfied with Bill's justice, the prostitutes put a bounty on the cowboys. The bounty attracts a young gun billing himself as 'The Schofield Kid', and aging killer William Munny. Munny reformed for his young wife, and has been raising crops and two children in peace. But his wife is gone. Farm life is hard. And Munny is no good at it. So he calls his old partner Ned, saddles his ornery nag, and rides off to kill one more time, blurring the lines between heroism and villainy, man and myth.",
     "country": "USA",
     "director": {
         "last_name": "Eastwood",
         "first_name": "Clint",
         "birth_date": "1930"
     },
     "actors": [
         {
             "first_name": "Clint",
             "last_name": "Eastwood",
             "birth_date": "1930",
             "role": "William Munny"
         },
         {
             "first_name": "Gene",
             "last_name": "Hackman",
             "birth_date": "1930",
             "role": "Little Bill Dagget"
         },
         {
             "first_name": "Morgan",
             "last_name": "Freeman",
             "birth_date": "1937",
             "role": "Ned Logan"
         }
     ]
  }
  </code></pre>