2

Hi i using Azure CosmosDB database,I trying to query multiple data in items .' In Collection is three array author_documents,book_documents,joining_documents. All data are filled up in these arrays. The Collection have this data:

[
    {
        "author_documents": [
            {
                "id": "a1",
                "name": "Thomas Andersen"
            },
            {
                "id": "a2",
                "name": "William Wakefield"
            }
        ],
        "book_documents": [
            {
                "id": "b1",
                "name": "Azure Cosmos DB 101"
            },
            {
                "id": "b2",
                "name": "Azure Cosmos DB for RDBMS Users"
            },
            {
                "id": "b3",
                "name": "Taking over the world one JSON doc at a time"
            },
            {
                "id": "b4",
                "name": "Learn about Azure Cosmos DB"
            },
            {
                "id": "b5",
                "name": "Deep Dive into Azure Cosmos DB"
            }
        ],
        "joining_documents": [
            {
                "authorId": "a1",
                "bookId": "b1"
            },
            {
                "authorId": "a2",
                "bookId": "b1"
            },
            {
                "authorId": "a1",
                "bookId": "b2"
            },
            {
                "authorId": "a1",
                "bookId": "b3"
            }
        ],
        "id": "33a127b7-a0b6-4207-8092-caf15aaae820",
        "_rid": "......",
        "_self": ".......",
        "_etag": "........",
        "_attachments": ".....",
        "_ts": .....
    },
    {
        "author_documents": [
            {
                "id": "a3",
                "name": "Thomas Andersen"
            }
        ],
        "id": "271ffe0c-56c1-4eec-be6c-a5b1d6ff6e72",
        "_rid": ".......",
        "_self": ".....",
        "_etag": "....",
        "_attachments": "......",
        "_ts": .....
    },
    {
        "book_documents": [
            {
                "id": "b7",
                "name": "Azure Cosmos DB 101"
            }
        ],
        "id": "c88a968e-4d4e-4a25-be6b-4661f314b7c5",
        "_rid": "....",
        "_self": "...",
        "_etag": ".....",
        "_attachments": ".....",
        "_ts": 1619172859
    },
    {
        "joining_documents": [
            {
                "authorId": "a3",
                "bookId": "b7"
            }
        ],
        "id": "9c7279ab-9e13-4a39-b61b-a03ad2b2652a",
        "_rid": "==",
        "_self": "/....",
        "_etag": ".......",
        "_attachments": "......",
        "_ts": .....
    }
]

With this query works fine:

SELECT t.authorId,t.bookId,f.name FROM  a 
join f in a.author_documents 
JOIN t IN a.joining_documents  where t.bookId="b2" and f.id = t.authorId

But with this query:

SELECT t.authorId,t.bookId,v.name FROM  a 
JOIN t IN a.joining_documents
join v in a.author_documents  where t.bookId="b7" and v.id = t.authorId

there is no records in database. I completely new with NoSQL databases. Why i cant query multiple items in collection?Is it possible to do that?

1 Answers1

1

Containers can't communicate between others in cosmosdb, as op said he choose to use MongoDb instead.

Tiny Wang
  • 10,423
  • 1
  • 11
  • 29
  • i want to query multiple items in collection,is it possible to do that? – Nikola Jokovic Apr 23 '21 at 16:44
  • Thanks for your response sir. Could you pls show me a sample of the query result you want, you can update your question like: I have a collection with documents like xxx, and I want a query which returns results like xxx. – Tiny Wang Apr 24 '21 at 08:44
  • At end i figure out that is CosmosDB is quite not flexibile as i want. .Containers cant communicate between others. So i moved on another database i mean on MongoDB. – Nikola Jokovic Apr 24 '21 at 10:38
  • Ok, that's fine. Could you pls delete this question? – Tiny Wang Apr 24 '21 at 13:19