In the spring of 2020, we released the latest revamp of the Couchbase SDK: 3.0. Shipping alongside Couchbase Server 6.5.0 and offering early, experimental support for Scopes and Collections, it also included a completely new API and consistency across the different platforms. While SDK 3.0 was a significant milestone in the Couchbase history, it was just another incremental improvement for developers working with Couchbase Server. Couchbase Server continues to evolve adding new features and that is why we are now releasing Couchbase SDK 3.1.0 with even more improvements for things such as FTS Geo Polygon support and Bucket Durability Management amongst others.

This post reviews each new feature added across all Couchbase SDKs. The examples are in C# but expect similar idiomatic implementations across all the SDKs whether it be Java, Go or another language.

FTS Geo Polygon Support

To augment the two types of Geo queries, Point Distance and Bounded Rectangle, already supported by Couchbase, in 6.5.0 Geo Bounded Polygon queries support was added. Point Distance queries are useful for finding things like restaurants near you and sorted distance near you. Bounded Rectangle Queries help find restaurants within a specific rectangular boundary near you, such as a city block. Geo Bounded Polygon Queries allows you to find restaurants within a random bounded polygon using an array of coordinate pairs as input parameters.

You can read more about Geo Polygon queries in this blog post.

Bucket Durability Management

Durability level guarantees persistence for documents; whether or not a document has been persisted to disk and how many replicas it has been written to.

In the older versions of Couchbase Server and SDK, durability level settings could only be provided via K/V Operation, this could quickly turn into a repetitive and mundane process especially in the case where persistence guarantees were to be the same across all documents within a Bucket. Starting Couchbase Server 6.6 we can now add Durability as a setting on the Bucket level. This feature is now available for you via SDK 3.1 Couchbase Server 6.6 adds Bucket level durability which allows for a certain durability to be applied to all documents within a bucket. In Couchbase SDK 3.1.0 we continue the support into the SDKs using the Bucket Management API.

The supported Durability levels are:

  • Majority – the document must have been replicated to a majority of the configured nodes in a cluster
  • MajorityAndPersistActive – the same as Majority but the document must also be persisted to the active node for durability requirements to be met.
  • PersistToMajority – the document must be persisted to a majority of the configured nodes on disk.

The default persistence level is none, but you can still specify the durability level upon insert or update of the document.

Bucket Ephemeral Management

This feature allows or the eviction policy for documents to be set for Ephemeral Buckets upon creation using the Management API.  The following eviction policies are now supported:

  • NRU Eviction – When the memory quota is reached, Couchbase Server ejects data that has not been used recently.
  • No Eviction – Couchbase Server keeps all data until explicitly deleted but will reject any new data if you reach the quota (dedicated memory) you set for your bucket.

Here is an example of setting NRU Eviction:

The default is No Eviction if not specified.

FTS Flex Index

FTS Flex Index

Flex Index gives the developer the ability to use the Couchbase Query Service to leverage search capabilities. For example, N1QL uses B-Tree indexes as they have selectivity and FTS uses inverted indexes which provide low selectivity or “fuzziness”; Flex Index allows you to combine for queries that are both exact and fuzzy by simply providing a hint to the service as to which behavior you desire. From the SDK this functionality is exposed but setting a simple flag on the QueryOptions object telling the N1QL service to consider using any FTS index to fulfill the query.

To use Flex Indexes simply set the FlexIndex property or method on the QueryOptions class.

FTS Score Parameter

As an optimization, scoring can now be disabled when doing Search queries. This is exposed as an option block parameter passed:

Scoring will be disabled if true is passed in, otherwise it will be included in the response.

GetResult.Expiry has been Deprecated

Finally, GetResult.Expiry has been deprecated and replaced with GetResult.ExpiryTime which specifies an instance in time as opposed to a duration.

Feedback please!

Those are the new features that have been added to Couchbase SDK 3.1 for Couchbase Server 6.6 and 7.0. We hope you find them useful and feel free to provide feedback on our forums or ask a Couchbase expert a question.

Posted by Jeff Morris, Senior Software Engineer, Couchbase

Jeff Morris is a Senior Software Engineer at Couchbase. Prior to joining Couchbase, Jeff spent six years at Source Interlink as an Enterprise Web Architect. Jeff is responsible for the development of Couchbase SDKs and how to integrate with N1QL (query language).

Leave a reply