CosmosDB 空间索引创建 - 错误?

CosmosDB spatial index creation - bug?

我创建了一个容器(使用 CosmosDB 模拟器),然后想为将出现在我的文档中的点 属性 添加空间索引。我正在使用 Microsoft.Azure.Cosmos (C#) SDK 创建空间索引,即:

// Clear any existing spatial indexes ...

container_properties.IndexingPolicy.SpatialIndexes.Clear();


// Add a spatial index for the geopoint (Point) property ...

spatial_path = new Microsoft.Azure.Cosmos.SpatialPath();

spatial_path.Path = "/geopoint/?";


// Add Point index type ...

spatial_path.SpatialTypes.Add( Microsoft.Azure.Cosmos.SpatialType.Point );

container_properties.IndexingPolicy.SpatialIndexes.Add( spatial_path );


// Update the container ...

container_response = await m_container.ReplaceContainerAsync( container_properties );

上面的代码执行成功。但是,当我检查通过模拟器创建的空间索引时,显示如下:

"spatialIndexes": [
        {
            "path": "/geopoint/?",
            "types": [
                "Point",
                "LineString",
                "Polygon",
                "MultiPolygon"
            ]
        }

问题 - 为什么代码只指定/添加了“Point”类型时显示“LineString”、“Polygon”和“MultiPolygon”类型?

提前致谢。

Why are the "LineString", "Polygon" and "MultiPolygon" types shown when the code only specified / added the "Point" type?

这不是 SDK 中的错误。这是设计使然。来自 Index geospatial data with Azure Cosmos DB 文档页面(强调我的):

Azure Cosmos DB supports indexing of Points, LineStrings, Polygons, and MultiPolygons. If you index any one of these types, we will automatically index all other types. In other words, if you index Polygons, we'll also index Points, LineStrings, and MultiPolygons. Indexing a new spatial type does not affect the write RU charge or index size unless you have valid GeoJSON data of that type.