0

Let's say I have the following document:

{
"Id": "1",
"Properties": [
    {
        "Name": "Name1",
        "PropertyTypes": [
            "Type1"
        ]
    },
    {
        "Name": "Name2",
        "PropertyTypes": [
            "Type1",
            "Type2",
            "Type3"
        ]
    }
]
}

When I use the following SQL:

SELECT c.Id FROM c
JOIN p in c.Properties
WHERE ARRAY_CONTAINS(p.PropertyTypes,"Type1")

I get as return:

[
{
    "Id": "1"
},
{
    "Id": "1"
}
]

How do I change my query so that it only returns distinct documents?

2

1 Answer 1

1

As far as I know, Distinct hasn't supported by Azure Cosmos DB yet.

It seems that there is no way to remove the repeat data in the query SQL level.

You could handle with your query result set in the loop locally.

However, if your result data is large,I suggest you using a stored procedure to handle with result data in Azure Cosmos DB to release the pressure on your local server.

You could refer to the official tutorial about SP.

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.