ArrayExpression multi nested arrays

Hi,

I got following documents:
> [

   {
      "docId":1,
      "variants":[
         {
            "price":10,
            "identifiers":[
               {
                  "id":1,
                  "value":"1"
               },
               {
                  "id":2,
                  "value":"2"
               }
            ]
         },
         {
            "price":15,
            "identifiers":[
               {
                  "id":3,
                  "value":"3"
               },
               {
                  "id":4,
                  "value":"4"
               }
            ]
         }
      ]
   },
   {
      "docId":2,
      "variants":[
         {
            "price":10,
            "identifiers":[
               {
                  "id":5,
                  "value":"5"
               },
               {
                  "id":6,
                  "value":"6"
               }
            ]
         },
         {
            "price":15,
            "identifiers":[
               {
                  "id":7,
                  "value":"7"
               },
               {
                  "id":8,
                  "value":"8"
               }
            ]
         }
      ]
   }
]

My question how for example query document which has identifier with value equal 7? I’d like to use ArrayExpression interface.

I already know how to write query which give me result for documents with price greater than 5, but I need to go even one nesting level further:

doc => variants (arr) => identifiers (arr) => value (property).

Is that possible at all?

Earlier I was doing such kind of queries (with only one level of nesting::

ArrayExpression.Any(ArrayExpression.Variable(“VARIANTS”)).In(Expression.Property(“variants”)).Satisfies(ArrayExpression.Variable(“VARIANTS.price”).GreaterThan(Expression.Int(15)))

Thanks in advance!

Kind Regards,
Piotr

There is no way, at present, to do what you wish to do, in a Query. You will have to use a query to get any documents that might match, with one layer of nesting, and then to do a brute force search of those documents.

We realize that this is an opportunity to improve our query language and are looking into a solution as I write this. Stay tuned.

@blake.meike - Thanks for an answer.

-Piotr

I think you can nest another Any expression inside the Satisfies test of the outer one.

Hi @piotr.czarnecki, I am facing a similar problem where we have an array inside an array and wanted to query something from the inner array. Did you get a solution for this?
@blake.meike Do we have a solution available for this now, we are currently using couchbase lite 2.7.
@jens Can you please elaborate a little, I tried something similar by passing another array expression inside an array expression but that didn’t work.

I have created https://issues.couchbase.com/browse/CBL-1248 to check on the nested array expression.