Skip to content

Instantly share code, notes, and snippets.

@couchtim
Created August 16, 2012 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save couchtim/3372689 to your computer and use it in GitHub Desktop.
Save couchtim/3372689 to your computer and use it in GitHub Desktop.
Java Couchbase: Found 81 docs. This view result doesn't contain documents
/* When I run this, I get:
[root@localhost java]# java CouchbaseView.App
2012-08-16 11:09:29.316 INFO com.couchbase.client.CouchbaseConnection: Added {QA sa=/10.4.2.13:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2012-08-16 11:09:29.380 INFO com.couchbase.client.CouchbaseClient: viewmode property isn't defined. Setting viewmode to production mode
2012-08-16 11:09:29.383 INFO com.couchbase.client.CouchbaseConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@377653ae
2012-08-16 11:09:29.426 INFO net.spy.memcached.auth.AuthThread: Authenticated to 10.4.2.13/10.4.2.13:11210
2012-08-16 11:09:29.495 INFO com.couchbase.client.ViewConnection: Added 10.4.2.13/10.4.2.13:8092 to connect queue
2012-08-16 11:09:29.926 INFO com.couchbase.client.http.AsyncConnectionManager: Opening new CouchDB connection
2012-08-16 11:09:29.933 INFO com.couchbase.client.http.AsyncConnectionManager$ConnRequestCallback: /10.4.2.13:8092 - Session request successful
Found 81 docs.
Error testing Couchbase: This view result doesn't contain documents
[root@localhost java]#
*/
CouchbaseClient cbc;
try {
List<URI> baseURIs = new ArrayList<URI>();
baseURIs.add(new URI("http://10.4.2.13:8091/pools"));
cbc = new CouchbaseClient(baseURIs, "gamesim-sample", "");
View view = cbc.getView("players", "leaderboard");
Query myQuery = new Query();
//myQuery.setRange("M", "N");
ViewResponse queryResults = cbc.query(view, myQuery);
Iterator<ViewRow> walkthrough = queryResults.iterator();
System.err.println("Found " + queryResults.size() + " docs.");
while (walkthrough.hasNext()) {
ViewRow next = walkthrough.next();
System.err.println(next.getDocument());
}
System.exit(0);
} catch (Exception e) {
System.err.println("Error testing Couchbase: " + e.getMessage());
System.exit(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment