I'm trying to implement a very basic C application that queries a Couchbase view using the C SDK. I got the SDK as such working since I can retrieve data from the DB server and even query views with a range query (startkey and endkey). However, if I create a view with a compound key, i.e. an index with two values, then I get nothing back. If I implement the same view in PHP or Node I get the correct data back. My understanding of the C SDK is that it uses the REST API of Couchbase, so the options string (optstr) is essentially the same as if I would use the Couchbase in-built web management console. Using single numeric start and end keys I get it all to work, but as soon as I start using compound keys like
startkey=["test",2]&endkey=["test",4]
I get no results back. The query string that does return data looks like
startkey=2&endkey=4
The bucket has only 5 documents of the following structure:
{number: 1, name: "test"}
with the number simply being between 1 and 5.
the view for the compound key looks like:
function (doc, meta) {
emit([doc.name, doc.number], doc);
}
and the one for the single key simply has the doc.number as the first value in the emit without being an array.
The code that I'm using for the compound key in C looks like:
lcb_CMDVIEWQUERY vq = {0};
vq.optstr = "startkey=[\"test\",2]&endkey=[\"test\",4]";
vq.noptstr = strlen(vq.optstr);
lcb_view_query_initcmd(&vq, "ddoc", "myView", NULL, viewCallback);
lcb_error_t rc = lcb_view_query(instance, NULL, &vq);
What am I missing for the compound views? The examples on the Couchbase website don't cover views using any keys and the examples in their Git repository don't have any examples either. The Couchbase C SDK seems to be a but light on documentation, even the API documentation doesn't seem to be very detailed.
Any help is appreciated.