In this post I quickly explain how to filter items of a Cosmos DB container based on nested properties by using Data Explorer of Azure Cosmos DB account in Azure portal.
Suppose there is a container named People
and the following item structure.
{
"person": {
"firstName": "John",
"lastName": "Doe",
"personId": "1234",
"addresses": [
{
"street": "Arbitrary street",
"zipCode": "23456",
"city": "Arbitrary city",
"country": "Arbitrary country",
"status": "Active"
}
],
},
"id": "1234",
"partitionKey": "people",
"_rid": "...==",
"_self": "...",
"_etag": "...",
"_attachments": "attachments/",
"_ts": 1659705160
}
In Data Explorer of Azure Cosmos DB account, select the corresponding container and then select Items
. Now the default filter can be extended by clicking on the Edit Filter
button.

To filter for person items with lastName
equals Doe
, the query part to add looks as follows:
WHERE c["person"].lastName = "Doe"
To filter for person items with address(es) in status Active
, the query part to add looks as follows:
WHERE ARRAY_CONTAINS(c["person"].addresses, {"status": "DeniedByAll"}, true)
Leave a Reply