Is there an ArrayFunction.containsAny() method or similar?

Hi. For my use case, I have a list of security “groups”. I only want to show objects that contain one of those “groups” as a “reader”. Example json:

{
"security": {
    "readers": [
        "group1",
        "group2"
     ]
}

In this example I want to return any objects that contain one or more of "group1", "group2""groupN", where the number of groups could be 100 or more. The only way I know to do this is

ArrayFunction.contains(Expression.property("security.readers"), Expression.string("group1"))
    .or(ArrayFunction.contains(Expression.property("security.readers"), Expression.string("group2")))
    ...
    .or(ArrayFunction.contains(Expression.property("security.readers"), Expression.string("groupN")))

This creates a lot of nested OR expressions, to the point that I get this error:

E/GetFiltersKt$updateFiltersAsync: CouchbaseLiteException{domain='CouchbaseLite', code=23, msg=JSON parse error: JSON error: LEVELS_EXCEEDED}
        at com.couchbase.lite.CBLStatus.convertException(CBLStatus.java:51)
        at com.couchbase.lite.CBLStatus.convertException(CBLStatus.java:55)
        at com.couchbase.lite.AbstractQuery.check(AbstractQuery.java:302)
        at com.couchbase.lite.AbstractQuery.execute(AbstractQuery.java:143)
        at com.couchbase.lite.Where.execute(Where.java:26)
        at com.myapp.database.DatabaseWrapper.getFilters(DatabaseWrapper.kt:446)
Caused by: LiteCoreException{domain=1, code=23, msg=JSON parse error: JSON error: LEVELS_EXCEEDED}
        at com.couchbase.litecore.C4Query.init(Native Method)
        at com.couchbase.litecore.C4Query.<init>(C4Query.java:31)
        at com.couchbase.litecore.C4Database.createQuery(C4Database.java:252)
        at com.couchbase.lite.AbstractQuery.check(AbstractQuery.java:300)
        at com.couchbase.lite.AbstractQuery.execute(AbstractQuery.java:143) 
        at com.couchbase.lite.Where.execute(Where.java:26) 
        at com.myapp.database.DatabaseWrapper.getFilters(DatabaseWrapper.kt:446) 

Is there another way to query arrays that would satisfy my use case, such as a (hypothetical) “ArrayFunction.containsAny()” method to see if an array contains any of the values of the provided array? Or is there a way to remove the level limit from the json parser?

Thanks,
Peter

Off the top of my head this seems like it would be solved by something like this:

ArrayExpression.any(ArrayExpression.variable("x")) .in(Expression.property("security.readers")) .satisfies(ArrayExpression.variable("x").Like("group%"))

Thanks @borrrden, but I’m afraid that won’t work. The groups that I am trying to match don’t follow a pattern, I was just using “groupN” as a way to say there could be many groups. In reality, they can be any string such as “demo” or “developers” or “sales”, etc.

Instead of like you can use an in expression to test if the array item is in a list of strings you provide.