I’ve tried to create a new document and getting it through the n1ql rest interface. I’ve read in a previous posting that the request_plus param is there to prevent the query to get an empty resultset after an insert. Unfortunately it doen’t seem to work for me. Below my code snippet:
$translation = new Translation();
$translation->date_created = $this->di->get('time')->format(\DateTime::ISO8601);
$translation->translation_type_id = $voiceCall->sid;
$translation->save();
$query = "statement=SELECT * FROM bucket where type = 'translation' order by date_created desc limit 1 &scan_consistency=request_plus";
print "\n".$query."\n\n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://myserver:8093/query/service');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
$resjson = json_decode($result, true);
if (isset($resjson['errors'])) {
throw new \CouchbaseException($resjson['errors'][0]['msg'], 999);
}
print_r($resjson);
thanks for your response. It’s a bit frustrating because it said in the release notes that the scan consistency feature is supported. I’ve wasted an entire day trying to debug this thing because I assumed that it would solve the query problem. I’ll now have to find a workaround because using a sleep timer is not a good practice at all.
Let me have my colleagues confirm this on Monday. If the release notes say it is supported, then I misspoke. We will do whatever it takes to get you a version with scan consistency.
Scan consistency is not really implemented in DP4 for views. Probably an error in the docs. It is implemented though in the current codebase but won’t be available until the next release.
Also FYI, by default if no stale= parameter is specified the view engine assumes stale=update_after. What this means is that the view is updated right after a query. What this means for you is that if you ran the same query twice, you would get the correct results second time around :).
Hi @willewolle, we are expecting it to be in Q2/Q3 at this point but we are gated on the quality of the product so the date may change based on feedback. There will however be a developer preview soon in a few weeks time. So if you have tolerance to play with early builds, you will get the opportunity to do that soon.