title: CouchDB Map/Reduce view query from Ektorp
body: <p>I'm trying to execute a query from java against a Map/Reduce view I have created on the CouchDB.
  My map function looks like the following:</p>
  
  <pre><code>function(doc) {
    if(doc.type == 'SPECIFIC_DOC_TYPE_NAME' &amp;&amp; doc.userID){
      for(var g in doc.groupList){
          emit([doc.userID,doc.groupList[g].name],1);
      }
    }
  }
  </code></pre>
  
  <p>and Reduce function:</p>
  
  <pre><code>  function (key, values, rereduce) {
          return sum(values); 
  }
  </code></pre>
  
  <p>The view seems to be working when executed from the Futon interface (without keys specified though).
  What I'm trying to do is to count number of some doc types belonging to a single group. I want to query that view using 'userID' and name of the group as a keys.</p>
  
  <p>I'm using Ektorp library for managing CouchDB data, if I execute this query without keys it returns the scalar value, otherwise it just prints an error saying that for reduce query group=true must be specified. </p>
  
  <p>I have tried the following:</p>
  
  <pre><code>ViewQuery query = createQuery("some_doc_name");
          List&lt;String&gt; keys = new ArrayList&lt;String&gt;();
          keys.add(grupaName);
          keys.add(uzytkownikID);
          query.group(true);
          query.groupLevel(2);
          query.dbPath(db.path());
          query.designDocId(stdDesignDocumentId);
          query.keys(keys);
          ViewResult r = db.queryView(query);
          return r.getRows().get(0).getValueAsInt();
  </code></pre>
  
  <p>above example works without 'keys' specified.
  I have other queries working with ComplexKey like eg:</p>
  
  <pre><code>ComplexKey key = ComplexKey.of(userID);
  return queryView("list_by_userID",key);
  </code></pre>
  
  <p>but this returns only a list of type T (List) - using CouchDbRepositorySupport of course - and cannot be used with reduce type queries (from what I know).</p>
  
  <p>Is there any way to execute the query with reduce function specified and a complex key with 2 or more values using Ektorp library? Any examples highly appreciated.</p>