1

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"

  • generally I just keep seeing SELECT *' is only valid with a single input set.

Any ideas would be appreciated.

Thanks

2
  • Any issues you met? What's the data result you want? Commented Aug 1, 2019 at 2:15
  • I want to get any documents where the schema:code array contains a string 7dhs Commented Aug 1, 2019 at 2:18

1 Answer 1

1

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

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

3 Comments

One thing - say I wanted to get teh entire document back SELECT * from c doenst seem to work
@userMod2 Yes,same for me. You could try workaround: select c.a,c.b,c.c,c.d.... from c,maybe that could work.
Yep - that helps. Wonder why one can't use Select * in this case

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.