'Filter the document if any value of the provided list is present in the document's array

Document

    {
    "status": {
            "active": [
                "A",
                "B"
            ],
            "inactive": [
                "C",
                "D"
            ]
        }
    }

Code

Criteria statusFilterCriteria = Criteria.getInstance(
   CriteriaType.ARRAY_CONTAINS,
   "status.active",   
   Collections.singletonList("A"), 
   Part.IgnoreCaseType.NEVER);
CosmosQuery cosmosQuery = new CosmosQuery(statusFilterCriteria);

The filtering criteria is that if any value of the list is present in the active array, then the Document should be returned. Since A is present in active array I get A in response. But when I pass A and B both in the list, I don't get the Document in my response.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source