Couchbase Ruby SDK 3.9
The Couchbase Ruby SDK allows Ruby applications to access a Couchbase cluster — Capella or self-managed. The Ruby SDK includes high-performance native Ruby extensions to handle communicating to the cluster over Couchbase’s binary protocols.
A fast and scalable database is even better when it’s easy to develop for. Couchbase gives you the Ruby APIs to work with Capella, our managed solution, or self-managed options in your private Cloud or datacenter.
-
Data Ops (CRUD)
-
SQL++ Query (OLTP)
-
Vector Search
agent_scope = bucket.scope("tenant_agent_00")
users_collection = agent_scope.collection("users")
document = {"name" => "John Doe", "preferred_email" => "johndoe111@test123.test"}
result = users_collection.upsert("user-key", document)
options = Cluster::QueryOptions.new
options.named_parameters({"country" => "France"})
result = cluster.query(
'SELECT COUNT(*) AS airport_count FROM `travel-sample` WHERE type = "airport" AND country = $country',
options)
puts "Airports in France: #{result.rows.first["airport_count"]}"
#=> Airports in France: 221
request = SearchRequest.new(
VectorSearch.new(
[
VectorQuery.new('vector_field', vector_query) do |q|
q.num_candidates = 2
q.boost = 0.3
end,
VectorQuery.new('vector_field', another_vector_query) do |q|
q.num_candidates = 5
q.boost = 0.7
end,
],
Options::VectorSearch.new(vector_query_combination: :and)
)
)
result = scope.search('vector-index', request)
result.rows.each do |row|
puts "Document ID: #{row.id}, search score: #{row.score}"
end
Couchbase is a large platform — covering many services — and Couchbase SDKs are not thin wrappers generated around a REST API, but well thought out interfaces to the platform that make it easier to design and maintain your client code, and work with Couchbase in more natural ways for your platform. Install the SDK, and explore in the way that works best for you.
$ gem install couchbase
The Couchbase Ruby SDK integrates into the Ruby ecosystem through a number of extensions and connectors, including:
Exploring the Ruby SDK
The links in the sections below will take you where you want to go — as will the navigation on the left-hand side of this page. But if you don’t know exactly where you need to go, try one of the following:
-
Our Quickstart Guide introduces the SDK with a quick install, and CRUD examples against the Data Service.
-
Couchbase’s familiar SQL-family query language and fuzzy search options (including vector search) are introduced on the Querying Your Data page.
-
The Ruby SDK docs are, necessarily, just a sub-set Ruby SDK API Reference — and a complete listing of all APIs can be found in the reference.
-
For a fuller orientation, there is a guide to the Ruby SDK docs
Using Your Database
How-to guides to help you start your development journey with Couchbase and the Ruby SDK.
Resources
Useful resources to help support your development experience with Couchbase and the Ruby SDK.
Couchbase Operational Cluster Feature Compatibility
All of the SDKs have API compatibility with most of the features in Couchbase Operational Clusters — whether self-managed, or Capella. The following table covers possible exceptions, and gives the version of the Ruby SDK and Couchbase Server with which some features were introduced.
| Server 7.2 | Server 7.6.x | Server 8.0 | |
|---|---|---|---|
KV Range Scan |
N/A |
From 3.4.4 |
|
Zone aware replica reads |
N/A |
From 3.5.5 |
|
Vector Search with Search Vector Index |
N/A |
From 3.5.0 |
|
Vector Query using Hyperscale Vector Index |
N/A |
From SDK 3.7.0 ① |
|
Vector Query using Composite (GSI & vector) index |
N/A |
From SDK 3.7.0 ① |
|
Distributed ACID Transactions |
N/A |
||
DNS SRV refresh for serverless environments (AWS Lambda, Azure Functions, and GCP Functions) |
From 3.4.0 |
||
Circuit Breakers |
Unsupported |
||
Response Time Observability with OTel |
From 3.8.0 |
||
Field Level Encryption |
N/A |
||
Cloud Native Gateway |
Unsupported |
||
| 1 | As part of the standard SDK SQL++ API, it should be compatible with all earlier versions of the SDK — but it has not been tested. |
|
Operational Insights SDKs
SDKs for Operational Insights Enterprise — Couchbase’s analytical database for real time apps and operational intelligence (RT-OLAP) — are available for the .NET, Go, Java, Node.js, and Python platforms. See the Operational Insights Enterprise SDK pages for more information. Currently, different SDKs are needed to connect to Operational Insights Capella — as this service does not have Operational Insights Enterprise’s load balancer, and uses a different connection protocol. Operational Insights Capella SDKs (also known as Columnar SDKs) are available for the Go, Java, Node.js, and Python platforms. See the Operational Insights Capella (Columnar) SDK pages for more information. |