A newer version of this documentation is available.

View Latest

Data Types

An instance of Couchbase Analytics data model can be a *primitive type* (BOOLEAN, STRING, BIGINT, or DOUBLE), a *special type* (NULL or MISSING), or a *composite type* (OBJECT or ARRAY).

The type names are case-insensitive, e.g., both BIGINT and bigint are acceptable.

Primitive Types##


boolean data type can have one of the two values: *true* or *false*.

  • Example:

    { "true": true, "false": false };
  • The expected result is:

    { "true": true, "false": false }


string represents a sequence of characters. The total length of the sequence can be up to 2,147,483,648.

  • Example:

    { "v1": string("This is a string."), "v2": string("\"This is a quoted string\"") };
  • The expected result is:

    { "v1": "This is a string.", "v2": "\"This is a quoted string\"" }


Bigint type uses 64 bits. The range of Bigint is:

  • bigint: -9223372036854775808 to 9223372036854775807

  • Example:

    { "bigint": bigint("1700000000000000000") };
  • The expected result is:

    { "bigint": 1700000000000000000 }

Double (double precision)

double represents approximate numeric data values using 8 bytes. The range of a double value can be from (2^(-1022)) to (2-2^(-52))·2^(1023) for both positive and negative. Beyond these ranges will get INF or -INF.

  • Example:

    { "v1": double("NaN"), "v2": double("INF"), "v3": double("-INF"), "v4": "-2013.593823748327284" };
  • The expected result is:

    { "v1": "NaN", "v2": "INF", "v3": "-INF", "v4": -2013.5938237483274 }

Double precision is an alias of double.

Incomplete Information Types##


null is a special value that is often used to represent an unknown value. For example, a user might not be able to know the value of a field and let it be null.

  • Example:

    { "field": null };
  • The expected result is:

    { "field": null }


missing indicates that a name-value pair is missing from an object. If a missing name-value pair is accessed, an empty result value is returned by the query.

As neither the data model nor the system enforces homogeneity for datasets or collections, items in a dataset or collection can be of heterogeneous types and so a field can be present in one object and missing in another.

  • Example:

    { "field": missing };
  • The expected result is:

    {  }

Since a field with value missing means the field is absent, we get an empty object.

Composite Types


An object (a.k.a., JSON object) contains a set of fields, where each field is described by its name.

Syntactically, object constructors are surrounded by curly braces "{…​}". For example:

{ "name": "Joe Blow", "rank": "Sergeant", "serialno": 1234567 }
{ "rank": "Private", "serialno": 9876543 }
{ "name": "Sally Forth", "rank": "Major", "serialno": 2345678, "gender": "F" }


An array is a container that holds a fixed number of values. Array constructors are denoted by brackets: "[…​]".

An example would be

["alice", 123, "bob", null]