Last active
September 13, 2016 20:55
-
-
Save Red-Folder/c2208f7d5ab8a6ea1694e0fbfdc2d119 to your computer and use it in GitHub Desktop.
Adding an index to a DocumentDB collection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DocumentClient client; | |
client = new DocumentClient(new Uri(endpointUri), primaryKey); | |
DocumentCollection resultCollection = client.ReadDocumentCollectionAsync(UriFactory.CreateDocumentCollectionUri(databaseName, collectionName)).Result; | |
resultCollection.Id = collectionName; | |
resultCollection.IndexingPolicy.IncludedPaths.Clear(); | |
resultCollection.IndexingPolicy.IncludedPaths.Add( | |
new IncludedPath | |
{ | |
Path = "/timestamp/?", | |
Indexes = new Collection<Index> { | |
new RangeIndex(DataType.String) { Precision = -1 } | |
} | |
}); | |
resultCollection.IndexingPolicy.IncludedPaths.Add( | |
new IncludedPath | |
{ | |
Path = "/*", | |
Indexes = new Collection<Index> { | |
new HashIndex(DataType.String) { Precision = 3 }, | |
new RangeIndex(DataType.Number) { Precision = -1 } | |
}, | |
}); | |
client.ReplaceDocumentCollectionAsync(resultCollection).Wait(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment