Skip to main content
Version: Next

Couchbase

Couchbase Sink Connector

Support Those Engines

Spark
Flink
SeaTunnel Zeta

Key features

Description

Writes data to a Couchbase collection. Each incoming row is stored as a JSON document. The document key is built from the primary-key fields using a length-prefixed canonical encoding (<len>:<value> components separated by #, e.g. 3:foo#3:bar). This encoding is collision-free: values that contain separators (#) or other special characters cannot produce the same key as distinct tuples. When no primary key is configured a random UUID is used.

The connector supports:

  • Upsert mode — insert or replace existing documents.
  • Batch flushing — buffer rows in memory and flush on size or time threshold.
  • Retry — transient write failures are retried with linear backoff (attempt n waits retry.interval × n milliseconds).

Supported DataSource Info

In order to use the Couchbase connector, the following dependency is required. It can be downloaded from the Maven Central Repository.

DatasourceSupported VersionsDependency
CouchbaseServer 7.x+Download

Database Dependency

Please install the connector plugin before running jobs:

sh bin/install-plugin.sh ${version}

Data Type Mapping

Couchbase stores JSON documents. The connector maps SeaTunnel types to JSON values as follows:

SeaTunnel Data TypeCouchbase JSON value
BOOLEANBoolean
TINYINT / SMALLINT / INTNumber (integer)
BIGINTNumber (long)
FLOAT / DOUBLENumber (floating point)
DECIMALString (exact decimal, e.g. "123.456")
STRINGString
DATE / TIME / TIMESTAMPString (ISO-8601)
BYTESString (Base64-encoded)
ARRAYArray (elements recursively converted)
MAPObject (keys coerced to String, values recursively converted)
ROWObject (nested JSON document)
NULLnull

Sink Options

NameTypeRequiredDefaultDescription
connection.stringStringYes-Couchbase connection string, e.g. couchbase://localhost.
usernameStringYes-Couchbase username.
passwordStringYes-Couchbase password.
bucketStringYes-Target bucket name.
scopeStringNo_defaultTarget scope name within the bucket.
collectionStringYes-Target collection name.
primary-keyList<String>No-Field names used to build the document key (length-prefixed encoding: <len>:<value> components separated by #). A random UUID is used when not set.
upsert-enableBooleanNofalseEnable upsert (insert-or-replace) mode. When false, duplicate keys will cause an error.
buffer-flush.max-rowsIntegerNo1000Maximum rows to buffer before a batch write is triggered. Use -1 to disable.
buffer-flush.intervalLongNo30000Maximum milliseconds between batch writes. Use -1 to disable.
retry.maxIntegerNo3Maximum retry attempts on transient write failure.
retry.intervalLongNo1000Base milliseconds for linear retry delay. Attempt n waits retry.interval × n ms.

Security

TLS / encrypted transport

For production deployments, use the couchbases:// scheme (note the trailing s) to enable TLS. Pass the CA certificate or a custom trust store through the Couchbase Java SDK's ClusterEnvironment:

sink {
Couchbase {
# Use couchbases:// (with trailing 's') for TLS-encrypted transport
connection.string = "couchbases://couchbase.example.com"
username = "seatunnel_writer"
password = "${env:COUCHBASE_PASSWORD}"
bucket = "my_bucket"
collection = "my_collection"
}
}

Refer to the Couchbase Java SDK — Secure Connections for TLS configuration, certificate pinning, client certificates, and cipher suite options.

Least-privilege service account

Do not use the built-in Administrator account in production. Create a dedicated Couchbase user with the minimal required role:

  • Data Writer on the target bucket/scope/collection (for insert-only workloads).
  • Data Reader + Data Writer (for upsert workloads that may need to read-before-write).

Credential protection

Avoid storing passwords in plain-text job configuration files. SeaTunnel supports encrypted configuration values — see the SeaTunnel credential encryption documentation for details on substituting secrets at runtime.

Task Example

Simple example (development only)

⚠️ The connection string and credentials below are for local development only. See the Security section above before deploying to production.

sink {
Couchbase {
connection.string = "couchbase://127.0.0.1"
username = "Administrator"
password = "password"
bucket = "my_bucket"
collection = "my_collection"
}
}

Upsert with composite document key (development only)

⚠️ The connection string and credentials below are for local development only. See the Security section above before deploying to production.

sink {
Couchbase {
connection.string = "couchbase://127.0.0.1"
username = "Administrator"
password = "password"
bucket = "my_bucket"
scope = "_default"
collection = "my_collection"
primary-key = ["user_id", "order_id"]
upsert-enable = true
buffer-flush.max-rows = 500
buffer-flush.interval = 10000
retry.max = 5
retry.interval = 2000
}
}
Change Log
ChangeCommitVersion