Overview of Indexing Policies

Indexing in Cosmos DB

By default, Cosmos DB indexes every property in a document. This approach improves efficiency when we use the WHERE or ORDER BY clauses on a single property.

Property path mapping

It’s out of the scope of this lesson to teach how Cosmos DB creates indexes, but it’s interesting to have a small overview.

When requesting the creation of an item, the database does the following:

  • Projects the item as a JSON document.

  • Converts the item into a tree and updates indexes.

This process helps the engine extract the path of a value by traversing the tree and concatenating each node label.

For example, take a look at the following document:

Get hands-on with 1200+ tech skills courses.