public async static Task PopulateNarrowCollection(List <DgProvider> filteredProviders) { DocumentCollection narrowProviderCollection = new DocumentCollection { Id = BhProvidersDatabaseDa.CollectionNames.DgNarrowProviders.ToString() }; narrowProviderCollection.IndexingPolicy.IndexingMode = IndexingMode.Lazy; /* Index index = new Index(); * narrowProviderCollection.IndexingPolicy.IncludedPaths = new System.Collections.ObjectModel.Collection<IncludedPath>() * { * new IncludedPath * { * Indexes = new System.Collections.ObjectModel.Collection<Index>() * { new ; */ await BhProvidersDatabaseDa.CreateCollection(BhProvidersDatabaseDa.CollectionNames.DgNarrowProviders); Uri uri = UriFactory.CreateDocumentCollectionUri(BhProvidersDatabaseDa.DatabaseName, BhProvidersDatabaseDa.CollectionNames.DgNarrowProviders.ToString()); foreach (DgProvider provider in filteredProviders) { DataModels.Narrow.DgProvider narrow = provider; Task <ResourceResponse <Document> > task = BhProvidersDatabaseDa.DocumentClient.CreateDocumentAsync(uri, narrow); } Console.WriteLine($"Received {filteredProviders.Count}"); }
public async static Task PopulateLimitedIndexesCollection(List <DgProvider> narrowProviders) { Uri uri = UriFactory.CreateDocumentCollectionUri(BhProvidersDatabaseDa.DatabaseName, BhProvidersDatabaseDa.CollectionNames.LimtedIndexes.ToString()); //Delete collection if exists bool exists = BhProvidersDatabaseDa.DocumentClient.CreateDocumentCollectionQuery(BhProvidersDatabaseDa.DatabaseUri) .ToList() .Exists(c => c.Id == BhProvidersDatabaseDa.CollectionNames.LimtedIndexes.ToString()); if (exists) { await BhProvidersDatabaseDa.DocumentClient.DeleteDocumentCollectionAsync(uri); } //Set throughput and partition key int reservedRUs = 9000; string partitionKey = "/locations[0].zip"; PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); partitionKeyDefinition.Paths.Add(partitionKey); //Weird. Cannot have more than one partition key... RequestOptions requestOptions = new RequestOptions { OfferThroughput = reservedRUs }; DocumentCollection limitedIndexesCollection = new DocumentCollection { Id = BhProvidersDatabaseDa.CollectionNames.LimtedIndexes.ToString() }; limitedIndexesCollection.IndexingPolicy.IncludedPaths = new System.Collections.ObjectModel.Collection <IncludedPath>(); limitedIndexesCollection.IndexingPolicy.IncludedPaths.Add (new IncludedPath { Indexes = new System.Collections.ObjectModel.Collection <Index> { new HashIndex(DataType.String) { Precision = -1 }, new RangeIndex(DataType.String) { Precision = -1 } }, Path = "/whateverPath/*" }); limitedIndexesCollection.IndexingPolicy.IndexingMode = IndexingMode.Lazy; ResourceResponse <DocumentCollection> response = await BhProvidersDatabaseDa.DocumentClient.CreateDocumentCollectionAsync( BhProvidersDatabaseDa.DatabaseUri, new DocumentCollection { Id = BhProvidersDatabaseDa.CollectionNames.LimtedIndexes.ToString(), PartitionKey = partitionKeyDefinition }, requestOptions ); DocumentCollection collection = response.Resource; DocumentCollection narrowProviderCollection = new DocumentCollection { Id = BhProvidersDatabaseDa.CollectionNames.DgNarrowProviders.ToString() }; narrowProviderCollection.IndexingPolicy.IndexingMode = IndexingMode.Lazy; /* Index index = new Index(); * narrowProviderCollection.IndexingPolicy.IncludedPaths = new System.Collections.ObjectModel.Collection<IncludedPath>() * { * new IncludedPath * { * Indexes = new System.Collections.ObjectModel.Collection<Index>() * { new ; */ await BhProvidersDatabaseDa.CreateCollection(BhProvidersDatabaseDa.CollectionNames.DgNarrowProviders); foreach (DgProvider provider in filteredProviders) { DataModels.Narrow.DgProvider narrow = provider; Task <ResourceResponse <Document> > task = BhProvidersDatabaseDa.DocumentClient.CreateDocumentAsync(uri, narrow); } Console.WriteLine($"Received {filteredProviders.Count}"); }