Description
I am running couchbase server version 2.0.0 community edition (build-722) and the latest java couchbase client, couchbase-client-1.1-dp.jar
I realize all this is developer preview however, this seems pretty basic stuff for dp4. Can you help?
I have some simple test documents that look as follows
{ "account_id": "-2", "value": "2.00000000", "created_at": "2012-04-06 03:55:22", }and a simple view called counts in the transactions document defined as follows
function (doc)
{ emit([doc.account_id, doc.created_at], parseFloat(doc.value)); }with a _stats reduce function
I can correctly run queries using complex keys using the couchbase design view in the management interface, or issue requests from my browser / curl as follows
http://127.0.0.1:8092/default/_design/dev_transactions/_view/counts?group_level=2&startkey=["-1","2012-04-06 01:28:30"]&endkey=["-1","2012-04-07 01:49:26"]&group=true&reduce=true&stale=false
and get the correct response
{"rows":[
{"key":["-1","2012-04-06 03:55:21"],"value":{"sum":2,"count":1,"min":2,"max":2,"sumsqr":4}},
{"key":["-1","2012-04-06 03:55:22"],"value":{"sum":3,"count":1,"min":3,"max":3,"sumsqr":9}},
{"key":["-1","2012-04-06 03:55:33"],"value":{"sum":5,"count":2,"min":2,"max":3,"sumsqr":13}}
]
}
However when I try to do a range query from java I get a null result. If I leave off the range keys, everything works as would be expected.
A null result looks to me as if the server did not respond. But, using the debugger I can tell that the url is correctly created. Any thoughts?
CouchbaseClient couchbase = new CouchbaseClient(couchbaseURIs, "default", "");
Query query = new Query();
query.setRange("[\"-1\",\"2012-04-06 01:28:30\"]", "[\"-1\",\"2012-04-06 01:49:26\"]");
query.setGroup(true, 2);
query.setStale(Stale.FALSE);
query.setReduce(true);
query.setIncludeDocs(false);
View view = couchbase.getView("transactions", "counts");
if (view != null) {
ViewResponse result = couchbase.query(view, query);
ViewRow row;
Iterator<ViewRow> itr = result.iterator();
while(itr.hasNext())
{ row = itr.next(); System.out.println("Key: " + row.getKey()+ " : " + row.getValue()); } }
}