QuestionQ167

VerifiedDevelop for Azure storage

You are developing a new website page that uses Azure Cosmos DB for data storage. The feature uses documents in the following format:

Question Image

You must show data for the new page in a particular order. You create the following query for the page:

Question Image

You need to configure a Cosmos DB policy that supports the query. Each JSON segment may be used once, more than once, or not at all.

Drag & Drop
{
    "automatic": true,
    "indexingMode": "Consistent",
    "includedPaths": [
        {
            "path": "/*"
        }
    ], "excludedPaths": [],
    "": [
        [
            {
                "path": "/name", "order": "descending"
            },
            {
                "path": "/city", "order": ""
            }
        ]
    ]
}
Explanation

A multi-property ORDER BY requires a composite index. The composite paths must be in the same sequence as the sort properties, and each direction must match: name is ascending by default and city is descending. Thus the policy uses compositeIndexes with /name descending as supplied and /city descending; reversing every direction is also supported by Cosmos DB.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!