Define and Implement An Indexing Strategy For Azure Cosmos DB for NOSQL #TestSeries

On what operations of NoSQL, a default index is created?

Create, Update and Delete operations for any item are indexed and the index includes all the properties of the item.

What operations are performed by default indexes?

  • the inverted index is updated for all create, update or delete operations on an item
  • all properties of an item are automatically indexed
  • range indexes are used for strings and numbers

What are the components of setting an indexing policy?

  • Indexing Mode
  • Automatic
  • Included paths
  • Excluded path

What is the use of Indexing Mode?

This is used to find if indexing is enabled or not for the container. The default value is Consistent.

What should be updated to stop the indexing?

We need to set the indexing mode to None.

What should be set to stop the default indexing mode?

We need to set the Automatic component to disabled. The default value for this is Enabled.

What is the work of Included paths and excluded paths?

Included paths is the set of paths to include in the index. The default value is *. Excluded paths is the set of values to exclude from the index. The default value is the _etag property path.

Which indexing mode should be used when you want to update the index synchronously while performing individual operations such as create, update or delete?

Consistent

In which circumstances, is None indexing mode preferred?

  1. In case of bulk operations
  2. in case of point read operations

What is the meaning of the following symbols when setting up the property path

? – This indicates that the path terminates with a string or number(scalar) value

[] – this indicates that the path includes an array and avoids having to specify an array index values

* – this is a wildcard and matches any element in the current path.

You’ve created a bulk operation in Azure Cosmos DB for NoSQL that will insert hundreds of thousands of items into a container. You need to temporarily disable indexing and re-enable it after the bulk operation is complete. Prior to starting the bulk operation, which indexing mode should you configure in the indexing policy?

None

You’ve created a bulk operation in Azure Cosmos DB for NoSQL that will insert hundreds of thousands of items into a container. You need to temporarily disable indexing and re-enable it after the bulk operation is complete. Prior to starting the bulk operation, which indexing mode should you configure in the indexing policy?

 

*

How can we set the indexing policy using the .NET SDK?

Microsoft.Azure.Cosmos.IndexingPolicy

When creating a new instance of this class, we can immediately set the Indexing Mode and Automatic properties.

What should be the order of a composite index?

The composite index that supports the index must exactly match the sequence of the properties in the ORDER BY clause.

Using which property can we create composite indexes in .NET SDK?

To create a raw JSON indexing policy with a composite index, you should include the optional compositeIndexes array property. The external array consist of a series of internal arrays for each composite index definition.

You are writing a C# application that interfaces with Azure Cosmos DB for NoSQL and are now tasked with creating a custom indexing policy in code. Which class should you use to author your new indexing policy and customize the indexing mode, enable automatic updates, and set the include/exclude paths?

Indexing Policy

The most used query in your Azure Cosmos DB for NoSQL application is SELECT * FROM products p ORDER BY p.name ASC, p.price ASC. You would like to define a composite index to make the query more efficient and consume fewer RU/s. Which composite index should you use to support this query?

price ASC, name ASC

Foolishly Yours,
Avantika

Happy Learning 🙂



Leave a comment