Introduction

By default, the Azure Cosmos DB data is indexed. Azure applies its default indexing policy while creating a collection. However, the users can set their customized indexing policy as per the requirement.
Types of Index
The process of customizing the Indexing Policy
Default Indexing Policy
When creating a collection using the Azure portal, the Cosmos DB indexes both, strings and numeric properties, by default, with Range Index.
When creating a collection by code, Azure Cosmos DB, by default, indexes all the string properties within document consistently with a Hash index, and numeric properties with a Range index.
Indexing Modes
Index Paths
Path Description
/ Default path for collection. Recursive and applies to the whole document tree.
/prop/? Index path required to serve queries like the following (with Hash or Range types respectively):
SELECT FROM collection c WHERE c.prop = "value"
SELECT FROM collection c WHERE c.prop > 5
SELECT FROM collection c ORDER BY c.prop
/prop/* Index path for all paths under the specified label. Works with the following queries
SELECT FROM collection c WHERE c.prop = "value"
SELECT FROM collection c WHERE c.prop.subprop > 5
SELECT FROM collection c WHERE c.prop.subprop.nextprop = "value"
SELECT FROM collection c ORDER BY c.prop
/props/[]/? Index path required to serve iteration and JOIN queries against arrays of scalars like ["a", "b", "c"]:
SELECT tag FROM tag IN collection.props WHERE tag = "value"
SELECT tag FROM collection c JOIN tag IN c.props WHERE tag > 5
/props/[]/subprop/? Index path required to serve iteration and JOIN queries against arrays of objects like [{subprop: "a"}, {subprop: "b"}]:
SELECT tag FROM tag IN collection.props WHERE tag.subprop = "value"
SELECT tag FROM collection c JOIN tag IN c.props WHERE tag.subprop = "value"
/prop/subprop/? Index path required to serve queries (with Hash or Range types respectively):
SELECT FROM collection c WHERE c.prop.subprop = "value"
SELECT FROM collection c WHERE c.prop.subprop > 5