Skip to content

Instantly share code, notes, and snippets.

@jasonsirota
Created November 12, 2012 20:27
Show Gist options
  • Save jasonsirota/4061669 to your computer and use it in GitHub Desktop.
Save jasonsirota/4061669 to your computer and use it in GitHub Desktop.
homepage for matt
//instantiate the client
List<URI> uris = new LinkedList<URI>();
uris.add(URI.create("http://localhost:8091/pools"));
CouchbaseClient client = new CouchbaseClient(uris, "beer-sample", "");
//add a doc
String key = "beer_Wrath";
String value = "{'name':'Wrath','type':'beer','category':'Belgian and French Ale'}";
client.set(key, 0, value).get();
//define the query
View view = client.getView("beer", "by_name");
Query query = new Query().setKey("Wrath").setIncludeDocs(true);
//query the view and output
ViewResponse result = client.query(view, query);
System.out.printf("Query returned %s docs", result.size());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment