Skip to content

Instantly share code, notes, and snippets.

@ingenthr
Created January 14, 2012 20:20
Show Gist options
  • Select an option

  • Save ingenthr/1612750 to your computer and use it in GitHub Desktop.

Select an option

Save ingenthr/1612750 to your computer and use it in GitHub Desktop.
Accessing Couchbase 2.0 views
URI aserver = new URI("http://10.1.6.171:8091/pools/");
List<URI> servers = new ArrayList<URI>();
servers.add(aserver);
CouchbaseClient cbc = new CouchbaseClient(servers, "default", "");
System.err.println(cbc.get("MattIngenthron"));
View view = cbc.getView("$dev_testing", "atest");
Query myQuery = new Query();
myQuery.setRange("Bob", "N");
ViewFuture queryResultsFuture = cbc.query(view, myQuery);
ViewResponseWithDocs queryResults = queryResultsFuture.get();
Iterator<RowWithDocs> iterator = queryResults.iterator();
System.err.println("Found " + queryResults.numRecords() + " docs.");
while (iterator.hasNext()) {
RowWithDocs next = iterator.next();
System.err.println(next.getDoc());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment