title: How to get the document using view in couchbase
body: <p>I have a requirement wherein I have get the document from couchbase.</p>
  
  <p>Following in the Map function that I am using for the same - </p>
  
  <pre><code>function (doc, meta) {
     if (meta.type == "json" &amp;&amp; doc!=null) {
       emit(doc);
     }
  }
  </code></pre>
  
  <p>There is no reduce function. Also following is my java code to get the document - </p>
  
  <pre><code>  List&lt;URI&gt; hosts = Arrays.asList(
              new URI("http://&lt;some DNS with port&gt;/pools")
      );
  
      // Name of the Bucket to connect to
      String bucket = "Test-Sessions";
  
      // Password of the bucket (empty) string if none
      String password = "";
      //System.setProperty("viewmode", "development");
      // Connect to the Cluster
      CouchbaseClient client = new CouchbaseClient(hosts, bucket, password);
  
  
      String designDoc = "sessions";
      String viewName = "by_test";
      View view = client.getView(designDoc, viewName);
      Query query = new Query();
      query.setIncludeDocs(true);
      query.setKey(String.valueOf(122));
      ViewResponse result = client.query(view, query);
      Object object = null;
      for(ViewRow row : result) {
          if(null != row) {
          object = row.getDocument();
          }// deal with the document/data
      }
      System.out.println("Object" + object);
  </code></pre>
  
  <p>And the data that I have in couchbase is key - "122" and value - "true". But for some reason  , I do not get any rows in the ViewResponse. What is going wrong can anyone help?</p>