1

How can I return all documents which have parameter.code = "123", given this document structure, using CosmosDB SQL query? Is it necessary to use a UDF? (If so, how?)

{
    "batch_id": "abc",
    "samples": [
        {
            "sample_id": "123",
            "tests": [
                {
                    "parameter": {
                        "code": "123", // <- target
                    }
                }
            ]
        }
    ]
}
0

1 Answer 1

2

No need to use UDF(User Defined Function),just use cosmos db query sql with double JOIN.

SQL:

SELECT c.batch_id FROM c
join samples in c.samples 
join tests in samples.tests
where tests.parameter.code = "123"

Output:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.