userMod2
userMod2

Reputation: 9000

CosmosDB Query For Searching in a DB

I have the entries in my CosmosDB that following this structure:

{
    "id": "~results:123",
    "catalog:entity": [
        {
            "id": "~song.base:1da",
            "schema:name": "Autobiography",
            "schema:code": [
                "7dhs"
            ]
        },
        {
            "id": "~song.base:2da",
            "schema:name": "Autobiography",
            "schema:code": [
                "4lko"
            ]
        }
    ]
}

However I'm having issues in getting searching for those that contain a specific schema:code: that in exists in an array with a parent array catalog:entity.

I've tried a handful of things such as with no luck:

SELECT * FROM c JOIN schema:code IN c["catalog:entity"] WHERE schema:code IN "7dhs"

Any ideas would be appreciated.

Thanks

Upvotes: 1

Views: 67

Answers (1)

Jay Gong
Jay Gong

Reputation: 23792

Use sql:

SELECT c FROM c 
JOIN s IN c["catalog:entity"]
where array_contains(s["schema:code"],"7dhs",false)

Output:

enter image description here

Upvotes: 1

Related Questions