Couchbase

CALL apoc.couchbase.get(hostOrKey, bucket, documentId) yield id, expiry, cas, mutationToken, content

Retrieves a couchbase json document by its unique ID

CALL apoc.couchbase.exists(hostOrKey, bucket, documentId) yield value

Check whether a couchbase json document with the given ID does exist

CALL apoc.couchbase.insert(hostOrKey, bucket, documentId, jsonDocument) yield id, expiry, cas, mutationToken, content

Insert a couchbase json document with its unique ID

CALL apoc.couchbase.upsert(hostOrKey, bucket, documentId, jsonDocument) yield id, expiry, cas, mutationToken, content

Insert or overwrite a couchbase json document with its unique ID

CALL apoc.couchbase.append(hostOrKey, bucket, documentId, jsonDocument) yield id, expiry, cas, mutationToken, content

Append a couchbase json document to an existing one

CALL apoc.couchbase.prepend(hostOrKey, bucket, documentId, jsonDocument) yield id, expiry, cas, mutationToken, content

Prepend a couchbase json document to an existing one

CALL apoc.couchbase.remove(hostOrKey, bucket, documentId) yield id, expiry, cas, mutationToken, content

Remove the couchbase json document identified by its unique ID

CALL apoc.couchbase.replace(hostOrKey, bucket, documentId, jsonDocument) yield id, expiry, cas, mutationToken, content

Replace the content of the couchbase json document identified by its unique ID.

CALL apoc.couchbase.query(hostOrKey, bucket, statement) yield queryResult

Executes a plain un-parameterized N1QL statement.

CALL apoc.couchbase.posParamsQuery(hostOrKey, bucket, statement, params) yield queryResult

Executes a N1QL statement with positional parameters.

CALL apoc.couchbase.namedParamsQuery(hostOrKey, bucket, statement, paramNames, paramValues) yield queryResult

Executes a N1QL statement with named parameters.

Copy these jars into the plugins directory:

(Tested with CB Enterprise 5.5.3)

mvn dependency:copy-dependencies
cp target/dependency/java-client-2.5.9.jar target/dependency/core-io-1.5.2.jar target/dependency/rxjava-1.3.8.jar $NEO4J_HOME/plugins/

To interact with Couchbase you can define the host on which to connect to as the first parameter of the procedure (with bucket as second parameter, document_id as third parameter):

CALL apoc.couchbase.get('couchbase://Administrator:password@localhost', 'default', 'artist:vincent_van_gogh')

Otherwise you can use configuration properties in the same way as MongoDB. For example, you can add the following properties to the apoc.conf file:

apoc.couchbase.mykey.username=Administrator
apoc.couchbase.mykey.password=password
apoc.couchbase.mykey.uri=host1,host2,host3 // here you can define more than one hostname if you're using a cluster
apoc.couchbase.mykey.port=8091 // the bootstrapHttpDirectPort (optional)
CALL apoc.couchbase.get('mykey', 'default', 'artist:vincent_van_gogh')

You can also define some CouchbaseEnvironment parameters in the apoc.conf:

apoc.couchbase.connectTimeout=<default=5000>
apoc.couchbase.kvTimeout=<default=2500>
apoc.couchbase.ioPoolSize=<default=3>

In order to get an in-depth description of these configuration params please refer to the Official Couchbase Documentation

Configuration parameters

The procedures support the following config parameters:

Table 1. Config parameters
name type default description

collection

String

"_default"

the collection to use. See Scope and collections

scope

String

"_default"

the scope to use. See Scope and collections

compressionEnabled

boolean

true

If enabled, the client will compress documents before they are sent to Couchbase Server. See here.

compressionMinSize

Integer

32

Size in bytes. Documents smaller than this size are never compressed.

compressionMinRatio

Double

0.83

A value between 0 and 1. Specifies how "compressible" a document must be in order for the compressed form to be sent to the server.

mutationTokensEnabled

boolean

true

Mutation tokens allow enhanced durability requirements as well as advanced N1QL querying capabilities. Set this to false if you do not require these features and wish to avoid the associated overhead.

retryStrategy

Enum[FAILFAST, BESTEFFORT]

BESTEFFORT

The client’s default retry strategy. A retry strategy decides whether a failed operation should be retried. See here.

transcoder

Enum[DEFAULT, RAWJSON, RAWSTRING, RAWBINARY]

DEFAULT

The transcoder responsible for converting KV binary packages to and from Java objects.

connectTimeout

Long

null

The connection timeout (in milliseconds) used when a Bucket is opened. If null will be used the apoc.conf parameter apoc.couchbase.connectTimeout.

kvTimeout

Long

null

The Key/Value default timeout (in milliseconds) used on operations which are performed on a specific key. If null will be used the apoc.conf parameter apoc.couchbase.kvTimeout.

disconnectTimeout

Long

10000

The disconnect timeout (in milliseconds) is used when a Cluster is disconnected

queryTimeout

Long

75000

The Query timeout (in milliseconds) used on all N1QL query operations

analyticsTimeout

Long

75000

The Analytics timeout (in milliseconds) used on all Analytics query operations.

viewTimeout

Long

75000

The View timeout (in milliseconds) used on view operations. If there is a node failure during the request the internal cluster timeout is set to 60 seconds.

searchTimeout

Long

75000

The Search timeout is used on all FTS operations

configPollInterval

Long

2500

The interval at which the client fetches cluster topology information in order to proactively detect changes.

idleHttpConnectionTimeout

Long

4500

The length of time an HTTP connection may remain idle before it is closed and removed from the pool. Durations longer than 50 seconds are not recommended, since some services have a 1 minute server side idle timeout.

enableTcpKeepAlives

boolean

true

If enabled, the client periodically sends a TCP keepalive to the server to prevent firewalls and other network equipment from dropping idle TCP connections.

tcpKeepAliveTime

long

60000

The idle time after which a TCP keepalive gets fired. (This setting has no effect if enableTcpKeepAlives is false.) TODO

enableDnsSrv

boolean

true

Gets the bootstrap node list from a DNS SRV record. TODO

networkResolution

com.couchbase.client.core.env.NetworkResolution

null

The network resolution. See here for details.

trustCertificate

boolean

null

If not null, it is the path to a file containing a single X.509 certificate to trust as a Certificate Authority when establishing secure connections. This enable Tls, if present. See here for details.

waitUntilReady

Long

null

This method will wait until either the cluster state is "online" by default, or the timeout is reached.