Three multiple keys


#1

Hello.
@avsej

I have a question about multiple keys.

There are view type:

function (doc, meta) {
  if (meta.type == "json" && doc.type && doc.type == "fileCouple") {
    // Check if doc is JSON
    emit([doc.file, doc.prevFile, doc.case], {
      'docId': doc.docId,
      'createdAt': doc.createdAt,
      'updatedAt': doc.updatedAt,
      'file': doc.file,
      'prevFile': doc.prevFile,
      'case': doc.case
    });
    } else {
    }
}

I’m trying to run the following code:

$startKey = json_encode(["000aaa"], [], 0]);
$endKey = json_encode(["000aaa"], [], 100]);
$query = CouchbaseViewQuery::from("fileCouple", 'fileCoupleChain')->custom(["startkey" => $startKey, "endkey" => $endKey])->stale(CouchbaseViewQuery::UPDATE_BEFORE);
try {
    $res = $bucket->query($query);
    print_r($res);
    return $res->rows;
} catch (Exception $e) {
    return false;
}

But the request comes from the result when only three parameters are set.

How to make a request to the one required parameter. And the second optional. And to build on the result of the third parameter.

Thank you.


Again. Three multiple keys. Sorting
#2

with view queries, you can omit parameters from right to left. It is just ranging comparing all keys from map/reduce with the query.

if you need first and third key components to be mandatory during query, you have to reorder them and make third to be second when emitting.


#3

Thank you.
I’m going to try now.
@avsej