Skip to content

Commit

Permalink
fix: wrong composite indexes (#57)
Browse files Browse the repository at this point in the history
* Fix composite indexes.
---------
Co-authored-by: Luis Miranda Solari <[email protected]>
  • Loading branch information
luisms89 authored Sep 28, 2023
1 parent b42de29 commit d9b766b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/CosmosDbStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,17 @@ private async Task InitializeAsync(CancellationToken cancellationToken = default
};

// add the index policy
Collection<CompositePath> compositeIndexes = new ()
properties.IndexingPolicy.CompositeIndexes.Add(new Collection<CompositePath>
{
new CompositePath { Path = "/name", Order = CompositePathSortOrder.Ascending },
new CompositePath { Path = "/created_on", Order = CompositePathSortOrder.Ascending },
new CompositePath { Path = "/type", Order = CompositePathSortOrder.Ascending },
new CompositePath { Path = "/score", Order = CompositePathSortOrder.Ascending }
};

properties.IndexingPolicy.CompositeIndexes.Add(compositeIndexes);
new() { Path = "/name", Order = CompositePathSortOrder.Ascending },
new() { Path = "/created_on", Order = CompositePathSortOrder.Ascending }
});

properties.IndexingPolicy.CompositeIndexes.Add(new Collection<CompositePath>
{
new() { Path = "/type", Order = CompositePathSortOrder.Ascending },
new() { Path = "/score", Order = CompositePathSortOrder.Ascending }
});

ContainerResponse containerResponse = await resultDatabase.CreateContainerIfNotExistsAsync(properties, cancellationToken: cancellationToken);
Container = containerResponse.Container;
Expand Down

0 comments on commit d9b766b

Please sign in to comment.