Using CosmosDb and the .NET SDK, I can't seem to get the spatial index set the way I'm telling it.
NOTE: I am not creating any spatial indexes when the collection is created. I am updating it separately.
I am setting it for a single SpatialType of Point, but it still creates a list of all spatial types.
Here's my code:
containerResponse.Resource.IndexingPolicy.IndexingMode = IndexingMode.Consistent;
containerResponse.Resource.IndexingPolicy.SpatialIndexes.Clear();
containerResponse.Resource.IndexingPolicy.Automatic = true;
containerResponse.Resource.IndexingPolicy.SpatialIndexes
.Add(
new SpatialPath
{
Path = "/*",
SpatialTypes = { SpatialType.Point }
}
);
await Client.GetContainer(database, collection).ReplaceContainerAsync(containerResponse.Resource);
When I check the result in Azure Portal Data Explorer, I see this:
"spatialIndexes": [
{
"path": "/*",
"types": [
"Point",
"LineString",
"Polygon",
"MultiPolygon"
]
}
],
I can manually override it in the portal, but I'm trying to automate this.
Any idea what I'm doing wrong?
If it doesn't make any difference, then fine. Maybe someday I'll find another use for all those other spatial indexes, but I still don't know why it's not working.