Android ArrayExpression query result

Hallo I am writing an android app with Couchbase lite (my first contact with a no sql database). I will reduce my result with this query:

VariableExpression VAR_PACKAGES_MEDIA_SIZE = ArrayExpression.variable(“package.Media.Size”);
VariableExpression VAR_PACKAGES = ArrayExpression.variable(“package”);

   Query query =,
                .where(ArrayExpression.any(VAR_PACKAGES).in("Packages"))                             .satisfies(VAR_PACKAGES_MEDIA_SIZE.greaterThanOrEqualTo(Expression.intValue(35390))))

Here is my json

“APIVersion”: “0.1.4”,
"Packages": [
“Category”: “Arbeitssicherheit”,
“Description”: “Sie bringen Ihr …”,
"Media": {
“RetinaSize”: 57027,
“RetinaURL”: “package-2842/AS7-hochgelegen.jpg”,
"Size": 57027
“PackageID”: 2842,
“owner”: “demo”
“Category”: “Arbeitssicherheit”,
“Description”: “Sie bringen …”,
“Media”: {
“RetinaSize”: 15000,
“RetinaURL”: “package-18241/AS5-Büroarbeitsplätze.jpg”,
“Size”: 14000
“PackageID”: 18241,
“owner”: “demo”

My problem is I get always all the “Packages” entries, but I am getting all entries where"Media.Size" is greater or equals to 35390.

Is this not possible with Couchbase lite or is something wrong with my query.

Please where is the mistake


You need to use VAR_PACKAGE, the loop variable, in the satisfies expression.

Hello Jens,

thanks for your fast answer.

Sorry I have copied the wrong query into my question.

This is my my actual query:

VariableExpression VAR_PACKAGE_EXPRESSION  = ArrayExpression.variable("packages.Media.Size");
        VariableExpression VAR_PACKAGES = ArrayExpression.variable("packages");


Based on this blog: How to Query Array Collections in Couchbase Lite - The Couchbase Blog

The result is all entries from array “Packages” was returned (in this case 50 entries), but I need only the entries with Media.Size greater or equals 30000 ( in this case these are only 18 entries).

Thanks for your help

Your select clause specifies .Object.Packages, so you get that property value, which is the entire array. We don’t have a way currently to return only parts of an array. You can pick out those elements in your application code.
Privacy Policy | Update Marketing Preferences

Thanks for your answer Jens