Join Chander Dhall for an in-depth discussion in this video Create partitioned collection with custom indexing, part of Cosmos DB: Import, Manipulate, Index and Query.
- [Instructor] Now that we've created a partition, we can also create a partition with custom indexing. I'll go ahead and delete the lines of code we don't need and then change the method. It takes in the same amount of parameters and you can add another parameter, in case you have to do some kind of custom indexing. For now, we'll just go ahead and hard code it. To Collection dot Indexing Policy dot Indexing Mode.
In this case, I could say Indexing Mode is consistent. So, what does that really mean? There are three kinds of indexing modes here, we can say consistent, lazy, or none. And when you say "lazy," that means eventually there will be some kind of index created for that particular entry. So anytime we do a right, it will take us time and then create an index over a period of time. If we say "none," that particular resource will not have an index. And if we say "consistent," that means it will be consistent with the consistency level we have defined for that collection.
So, in this case, as you can see, we can add multiple request options and I'd like to add Consistency Level and say it's equal to Consistency Level dot Session. I could have chosen anything else including Bounded Staleness or Eventual. But for now, let's just pick Session. Now, we can run this like this. However, just to make sure we can see the entry, I'm going to go ahead and change the name to Test, and then do control F five.
And go back to the portal. Again in collections, browse, hit refresh. And you can see, we have Test, which is under database Cazton that just got created. Except, the difference is, Test Collection now has custom indexing.
- Data import scenarios
- Creating a database
- Creating a partitioned collection
- Data manipulation
- Importing documents with a stored procedure
- User-defined functions
- Excluding indexing at a document level
- Range indexing on strings
- Querying with SQL parameters
- Range operations