Parallel data management for complex queries over many records, using a familiar SQL-like syntax.
For complex and long-running queries, involving large ad hoc join, set, aggregation, and grouping operations, Couchbase Data Platform offers the Couchbase Analytics Service (CBAS). This is the analytic counterpart to our operational data focussed Query Service. The analytics service is available in Couchbase Data Platform 6.0 and later (developer preview in 5.5).
Getting Started
After familiarizing yourself with our introductory primer,
in particular creating a dataset and linking it to a bucket to shadow the operational data,
try Couchbase Analytics using the Ruby SDK.
Intentionally, the API for analytics is very similar to that of the query service.
In these examples we will be using an airports
dataset created on the travel-sample
bucket.
Queries
A query can either be simple
or be parameterized
.
If parameters are used, they can either be positional
or named
:
As timeouts are propagated to the server by the client, a timeout set on the client side may be used to stop the processing of a request, in order to save system resources. |
Options
Additional parameters may be sent as part of the query.
Name | Description |
---|---|
|
Provides a custom client context ID for this query; default is a random UUID. |
|
Allows certain requests to have higher priority than others. |
|
Allows explicitly marking a query as being read-only, and not mutating any documents on the server side. |
|
Specifies level of consistency for the query — |
|
The maximum duration (in milliseconds) the query engine is willing to wait before failing. |
|
Timeout in milliseconds. |
|
Transcoder to use on rows. |
Here, we set a client_context_id
:
And here we set high priority for the query:
Here we pass readonly
to explicitly mark a query as being read only, and not mutating any documents on the server side.
Handling the Response
The analytics query result may contain various sorts of data and metadata, depending upon the nature of the query, as you will have seen when working through our introductory primer.
Errors caused by resource unavailability (such as timeouts and Operation cannot be performed during rebalance messages) leading to an automatic retry by the SDK.
Scan Consistency
Like the Couchbase Query Service, and Search,
Analytics allows :request_plus
queries — ensuring results contain information from updated indexes: