Couchbase.NET SDK v2.2.7 w/Developer Preview of Index Management now available!

Today we are releasing version 2.2.7 of the official Couchbase .NET SDK! This release notably contains supports for Index management and adds to the Sub-Document API which was released as a developer preview in v2.2.6 as well as a bug fix and improvements in future support of .NET Core.

Index Management

Global Secondary Indexes (GSIs) are an important piece of the N1QL query architecture in Couchbase server allowing for fast, low latency queries. You can place indexes on JSON elements, N1QL expressions and using filters via a WHERE clause. For v2.2.7 of the .NET SDK we have built an abstraction over the Couchbase Server indexing service which makes it very easy to create primary and secondary indexes. This abstraction extends and widens the BucketManager class which includes support for creating and managing Couchbase Buckets.

The BucketManager is created by opening a Bucket object off a Cluster instance and passing in the correct configuration for your environment.

Creating and Dropping Primary Indexes

You can create named and unnamed primary indexes by calling the CreatePrimaryIndex and CreateNamedPrimaryIndex method once you have the BucketManager instance:

Note that you are always working with the context of the bucket you have opened. So these indexes will be created on the “beer-sample” bucket we opened earlier. Also, not that both of these methods take a boolean field called “defer”, in fact, as you’ll see, all creational methods contain a “defer” parameter. If “defer” is true, the index will be created, however, it will not be built until the BuildDeferredIndexes method is called. More about deferred indexes later!

Dropping a named or unnamed primary index is pretty much the same as creating an index with the exception of the method names:

Note that if the index does not exist, then result.Success will be false.

Creating and Dropping Secondary Indexes

Creating and dropping secondary indexes is similar to primary indexes except you can index on a one or more fields as well.

Note that in this case I am passing “true” so that the building of the index will be deferred. Also, if the index already exists or if it doesn’t exist and you try to drop it, result.Success will be false.

Updates to SubDocument API

This release also contains internal changes to the SubDocument API released as Developer Preview in 2.2.6. There are two major improvements related to performance were added:

  1. If a single mutation or lookup operation is executed the SDK will use a singular operation as opposed to a multi-operation which saves a few bytes over the wire.
  2. The deserialization of the response body is deferred now until you call Content

Lambda Expressions for Sub-Document path navigation

In addition to these changes, another new feature made its way into the release via a contribution from the community: Lambda expression navigation for Sub-Document paths. This feature allows you to use the familiar type-safe, intellisense supported syntax you enjoy from linq instead of just passing in string paths.

Assuming a document that looks like:

Then you retrieve the value at the path “geo.accuracy” like this:

Of course, you could chain multiple “Gets” to retrieve each individual element from the document.

Release Notes for v2.2.7

Bug

  • [NCBC-1099] – Add DataContract attribute to Error, Warning and Metrics classes

Improvement

  • [NCBC-1103] – Support for async operations on subdocuments
  • [NCBC-994] – Upgrade development environment and projects to VS2015
  • [NCBC-1089] – Await all not succesful code paths
  • [NCBC-1095] – Do not retry on NodeUnavailableException

New Feature

  • [NCBC-1067] – Extend BucketManager to support Index Management
  • [NCBC-1093] – Include support for Subdocument API – Part2 Single Commands DP2

How to get v2.2.7

  • Download the binaries here.
  • The NuGet package can be found here.
  • The Github repo is here.

Author

Posted by Madhuram Gupta

Leave a reply