Startkey, endkey whith multiple keys

Hello, @brett19.
Prompt please how to make a request to the start and end by multiple keys?

If I submit a request via the web, then it works.

But using PHP SDK, I get an empty result:

$query = CouchbaseViewQuery::from("fileActivity", 'toUserIdWithCreatedAt')->limit(50)->range(["startkey" => ["a056833fe94a", 0], "endkey" => ["a056833fe94a", 1385449958]]);

and

$query = CouchbaseViewQuery::from("fileActivity", 'toUserIdWithCreatedAt')->limit(50)->custom(["startkey" => ["a056833fe94a", 0], "endkey" => ["a056833fe94a", 1385449958]]);

not work.

Thank you.

I suspect the problem is either the difference in the inclusive_end or that the startkey and endkey arguments need to be JSON encoded strings that happen to be arrays, not passed as PHP arrays.

If you have a simple test case, I’d recommend turning the log level up to see the specific IO.

Hi Matt.
Your advice helped me a lot.
I did it:

$startKey = json_encode(["a056833fe94a", 0]);
$endKey = json_encode(["a056833fe94a", 1385449958]);
$query = CouchbaseViewQuery::from("fileActivity", 'toUserIdWithCreatedAt')->limit(100)->custom(["startkey" => $startKey, "endkey" => $endKey]);

Thanks @ingenthr

1 Like