Couchbase Lite 2 - query to get documents filtered by input array of strings


I want to write a query for documents with certain “identifiers”.
The document has a property called “identifier”.
The query should take an array of identifiers and return documents that are matching them.
The Input array is not a property of the document. It is simply an array to create the query.

Input Array [“identifierA”, “identifierB”, “identifierC”]
Document property [“identifier” : String]

I managed it to query all documents without a filter:

What I need is probably something like this:
.and(ArrayFunction.contains(ArrayExpression.any(Expression.string(“identifier”)), value: identifiers)
–> “identifiers” is an array of Strings

I’ve spent a whole day reading the documentation, your blogs and sample code but could not find what I need.

Kind regards,


The query should be of the form “WHERE identifier IN (…list of identifiers…)”. I don’t recall the exact syntax in the public API for an “IN” expression, sorry. (I work on the query engine but not on the API layer.)