Couchbase INdex update issue


#1

Hello,

I am facing an issue with the Couchbase INdex update. I am aware that this issue is there in Couchbase where it takes some time to update the view. But is there any option to force this index to update when I perform certain transaction?

Please help me on the below scenario -

  1. I do an insert on a bucket using the .NET SDK Insert API.
  2. Then I try to fetch the records using the N1QL query - First time the new record does not show up.
  3. Then I try once again to fetch the records using the N1QL query - the record shows up.

I do not have any views created on this bucket yet. It has just the #primary default view.

There are going to be scenarios when I want to insert a document and fetch 1000 documents from this bucket. These are large news documents and I dont want to fetch them twice just to refresh my views.

Please help!


#2

Hi,

Is it possible to post an example of a document you’re setting, and the query you are issuing? Also, which version of CB Server are you running this against?


#3

I am using the below versions -

Couchbase version: 3.0.2-1603 Enterprise Edition.
.NET SDk version: 2.0.2.0

This issue is not with any specific content, but with any document that I insert. Always it requires that I read the records for the second time when my newly inserted documents will show up.


#4

The default access pattern for querying against an index is to not control the index behavior and accept whatever the current state of the index is.

When you write a document and want to immediately retrieve it to “read your own write” the query needs to be bounded and the index needs to be updated to include the write. This is supported in the .net sdk with the QueryRequest.ScanConsistency Method. Documentation is available in the SDK API docs


#5

Hi Todd,

I tried the ScanConsistency with all the 3 different options RequestPlus, StatementPlus & AtPlus. But no luck :frowning:

Below is the code snippet. Please correct me if I am doing anything wrong.

var queryRequest = new QueryRequest(string.Format(“SELECT {0}.* FROM {0} USE KEYS [’{1}’]”, _bucketName, docId));
queryRequest.ScanConsistency(ScanConsistency.RequestPlus);
var n1QlResult = Connection.DbConnection.Bucket.Query(queryRequest);

Thanks,
Kris


#6

Kris,

The SDK has the feature implemented, and unfortunately as you demonstrated it’s not available on the server until the developer preview of Couchbase 4.0.

Thanks

Todd