skip to Main Content

I have something similar to the following json structure and I need to search for an specific filename in the Azure CosmosDB data explorer (no matter the position), I have been trying differents ways and also using CROSS APPLY FLATTEN but i cannot get it

{
"entityId": "f07256a5-0e60-412a-bcc9-2e1aa66b69f5",
"array1": [
    {
        
        "array2": [
            {
                "fileName": "filename1.pdf",
            },
            {
                "fileName": "filename2.pdf",
            }
        ]
    }
]

}

Any ideas? thanks

2

Answers


  1. This one works for me:

    SELECT c.entityId
    FROM c
    JOIN one IN c.array1
    JOIN two IN one.array2
    WHERE two.fileName = 'filename1.pdf'
    

    It uses self-joins to create an object for each filename and then filters from those which has the right filename.

    Login or Signup to reply.
  2. You need something like below,

    SELECT 
        c.fileName  
    FROM d
    JOIN f IN d.array1
    JOIN c IN f.array2
    WHERE c.fileName = "filename1.pdf"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search