Skip to content

Commit 123180c

Browse files
committed
geospatial updates and removed reference to index v1 properties
1 parent 316d128 commit 123180c

File tree

8 files changed

+110
-116
lines changed

8 files changed

+110
-116
lines changed

articles/cosmos-db/index-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Range indexes can be used on scalar values (string or number). The default index
147147
SELECT * FROM c WHERE ST_INTERSECTS(c.property, { 'type':'Polygon', 'coordinates': [[ [31.8, -5], [32, -5], [31.8, -5] ]] })
148148
```
149149
150-
Spatial indexes can be used on correctly formatted [GeoJSON](./sql-query-geospatial-intro.md) objects. Points, LineStrings, Polygons, and MultiPolygons are currently supported. To use this index type, set by using the `"kind": "Range"` property when configuring the indexing policy. To learn how to configure spatial indexes, see [Spatial indexing policy examples](how-to-manage-indexing-policy.md#spatial-index)
150+
Spatial indexes can be used on correctly formatted [GeoJSON](./sql-query-geospatial-intro.md) objects. Points, LineStrings, Polygons, and MultiPolygons are currently supported. To learn how to configure spatial indexes, see [Spatial indexing policy examples](how-to-manage-indexing-policy.md#spatial-index)
151151
152152
### Composite indexes
153153

articles/cosmos-db/index-policy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ A container's indexing policy can be updated at any time [by using the Azure por
335335
> Index transformation is an operation that consumes [Request Units](request-units.md). Request Units consumed by an index transformation aren't currently billed if you are using [serverless](serverless.md) containers. These Request Units will get billed once serverless becomes generally available.
336336
337337
> [!NOTE]
338-
> You can track the progress of index transformation in the Azure portal or [by using one of the SDKs](how-to-manage-indexing-policy.md).
338+
> You can track the progress of index transformation in the [Azure portal](how-to-manage-indexing-policy.md#use-the-azure-portal) or by [using one of the SDKs](how-to-manage-indexing-policy.md#dotnet-sdk).
339339
340340
There's no impact to write availability during any index transformations. The index transformation uses your provisioned RUs but at a lower priority than your CRUD operations or queries.
341341

articles/cosmos-db/nosql/how-to-manage-indexing-policy.md

Lines changed: 30 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -44,40 +44,6 @@ Here are some examples of indexing policies shown in [their JSON format](../inde
4444
}
4545
```
4646

47-
This indexing policy is equivalent to the one below which manually sets ```kind```, ```dataType```, and ```precision``` to their default values. These properties are no longer necessary to explicitly set and you should omit them from your indexing policy entirely (as shown in above example). If you try to set these properties, they'll be automatically removed from your indexing policy.
48-
49-
50-
```json
51-
{
52-
"indexingMode": "consistent",
53-
"includedPaths": [
54-
{
55-
"path": "/*",
56-
"indexes": [
57-
{
58-
"kind": "Range",
59-
"dataType": "Number",
60-
"precision": -1
61-
},
62-
{
63-
"kind": "Range",
64-
"dataType": "String",
65-
"precision": -1
66-
}
67-
]
68-
}
69-
],
70-
"excludedPaths": [
71-
{
72-
"path": "/path/to/single/excluded/property/?"
73-
},
74-
{
75-
"path": "/path/to/root/of/multiple/excluded/properties/*"
76-
}
77-
]
78-
}
79-
```
80-
8147
### Opt-in policy to selectively include some property paths
8248

8349
```json
@@ -99,48 +65,6 @@ This indexing policy is equivalent to the one below which manually sets ```kind`
9965
}
10066
```
10167

102-
This indexing policy is equivalent to the one below which manually sets ```kind```, ```dataType```, and ```precision``` to their default values. These properties are no longer necessary to explicitly set and you should omit them from your indexing policy entirely (as shown in above example). If you try to set these properties, they'll be automatically removed from your indexing policy.
103-
104-
105-
```json
106-
{
107-
"indexingMode": "consistent",
108-
"includedPaths": [
109-
{
110-
"path": "/path/to/included/property/?",
111-
"indexes": [
112-
{
113-
"kind": "Range",
114-
"dataType": "Number"
115-
},
116-
{
117-
"kind": "Range",
118-
"dataType": "String"
119-
}
120-
]
121-
},
122-
{
123-
"path": "/path/to/root/of/multiple/included/properties/*",
124-
"indexes": [
125-
{
126-
"kind": "Range",
127-
"dataType": "Number"
128-
},
129-
{
130-
"kind": "Range",
131-
"dataType": "String"
132-
}
133-
]
134-
}
135-
],
136-
"excludedPaths": [
137-
{
138-
"path": "/*"
139-
}
140-
]
141-
}
142-
```
143-
14468
> [!NOTE]
14569
> It is generally recommended to use an **opt-out** indexing policy to let Azure Cosmos DB proactively index any new property that may be added to your data model.
14670
@@ -377,36 +301,6 @@ To create a container with a custom indexing policy see, [Create a container wit
377301

378302
## <a id="dotnet-sdk"></a> Use the .NET SDK
379303

380-
# [.NET SDK V2](#tab/dotnetv2)
381-
382-
The `DocumentCollection` object from the [.NET SDK v2](https://www.nuget.org/packages/Microsoft.Azure.DocumentDB/) exposes an `IndexingPolicy` property that lets you change the `IndexingMode` and add or remove `IncludedPaths` and `ExcludedPaths`.
383-
384-
```csharp
385-
// Retrieve the container's details
386-
ResourceResponse<DocumentCollection> containerResponse = await client.ReadDocumentCollectionAsync(UriFactory.CreateDocumentCollectionUri("database", "container"));
387-
// Set the indexing mode to consistent
388-
containerResponse.Resource.IndexingPolicy.IndexingMode = IndexingMode.Consistent;
389-
// Add an included path
390-
containerResponse.Resource.IndexingPolicy.IncludedPaths.Add(new IncludedPath { Path = "/*" });
391-
// Add an excluded path
392-
containerResponse.Resource.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/name/*" });
393-
// Add a spatial index
394-
containerResponse.Resource.IndexingPolicy.SpatialIndexes.Add(new SpatialSpec() { Path = "/locations/*", SpatialTypes = new Collection<SpatialType>() { SpatialType.Point } } );
395-
// Add a composite index
396-
containerResponse.Resource.IndexingPolicy.CompositeIndexes.Add(new Collection<CompositePath> {new CompositePath() { Path = "/name", Order = CompositePathSortOrder.Ascending }, new CompositePath() { Path = "/age", Order = CompositePathSortOrder.Descending }});
397-
// Update container with changes
398-
await client.ReplaceDocumentCollectionAsync(containerResponse.Resource);
399-
```
400-
401-
To track the index transformation progress, pass a `RequestOptions` object that sets the `PopulateQuotaInfo` property to `true`.
402-
403-
```csharp
404-
// retrieve the container's details
405-
ResourceResponse<DocumentCollection> container = await client.ReadDocumentCollectionAsync(UriFactory.CreateDocumentCollectionUri("database", "container"), new RequestOptions { PopulateQuotaInfo = true });
406-
// retrieve the index transformation progress from the result
407-
long indexTransformationProgress = container.IndexTransformationProgress;
408-
```
409-
410304
# [.NET SDK V3](#tab/dotnetv3)
411305

412306
The `ContainerProperties` object from the [.NET SDK v3](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/) (see [this Quickstart](quickstart-dotnet.md) regarding its usage) exposes an `IndexingPolicy` property that lets you change the `IndexingMode` and add or remove `IncludedPaths` and `ExcludedPaths`.
@@ -463,6 +357,36 @@ await client.GetDatabase("database").DefineContainer(name: "container", partitio
463357
.Attach()
464358
.CreateIfNotExistsAsync();
465359
```
360+
361+
# [.NET SDK V2](#tab/dotnetv2)
362+
363+
The `DocumentCollection` object from the [.NET SDK v2](https://www.nuget.org/packages/Microsoft.Azure.DocumentDB/) exposes an `IndexingPolicy` property that lets you change the `IndexingMode` and add or remove `IncludedPaths` and `ExcludedPaths`.
364+
365+
```csharp
366+
// Retrieve the container's details
367+
ResourceResponse<DocumentCollection> containerResponse = await client.ReadDocumentCollectionAsync(UriFactory.CreateDocumentCollectionUri("database", "container"));
368+
// Set the indexing mode to consistent
369+
containerResponse.Resource.IndexingPolicy.IndexingMode = IndexingMode.Consistent;
370+
// Add an included path
371+
containerResponse.Resource.IndexingPolicy.IncludedPaths.Add(new IncludedPath { Path = "/*" });
372+
// Add an excluded path
373+
containerResponse.Resource.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/name/*" });
374+
// Add a spatial index
375+
containerResponse.Resource.IndexingPolicy.SpatialIndexes.Add(new SpatialSpec() { Path = "/locations/*", SpatialTypes = new Collection<SpatialType>() { SpatialType.Point } } );
376+
// Add a composite index
377+
containerResponse.Resource.IndexingPolicy.CompositeIndexes.Add(new Collection<CompositePath> {new CompositePath() { Path = "/name", Order = CompositePathSortOrder.Ascending }, new CompositePath() { Path = "/age", Order = CompositePathSortOrder.Descending }});
378+
// Update container with changes
379+
await client.ReplaceDocumentCollectionAsync(containerResponse.Resource);
380+
```
381+
382+
To track the index transformation progress, pass a `RequestOptions` object that sets the `PopulateQuotaInfo` property to `true`.
383+
384+
```csharp
385+
// retrieve the container's details
386+
ResourceResponse<DocumentCollection> container = await client.ReadDocumentCollectionAsync(UriFactory.CreateDocumentCollectionUri("database", "container"), new RequestOptions { PopulateQuotaInfo = true });
387+
// retrieve the index transformation progress from the result
388+
long indexTransformationProgress = container.IndexTransformationProgress;
389+
```
466390
---
467391

468392
## Use the Java SDK
190 KB
Loading

articles/cosmos-db/nosql/query/geospatial-intro.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,13 @@ Azure Cosmos DB interprets coordinates as represented per the WGS-84 reference s
101101
**LineStrings in GeoJSON**
102102

103103
```json
104+
{
104105
"type":"LineString",
105-
"coordinates":[ [
106+
"coordinates":[
106107
[ 31.8, -5 ],
107108
[ 31.8, -4.7 ]
108-
] ]
109+
]
110+
}
109111
```
110112

111113
### Polygons

articles/cosmos-db/nosql/query/spatial-functions.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,13 @@ Azure Cosmos DB supports the following Open Geospatial Consortium (OGC) built-in
1818

1919
The following scalar functions perform an operation on a spatial object input value and return a numeric or Boolean value.
2020

21+
* [ST_AREA](st-area.md)
2122
* [ST_DISTANCE](st-distance.md)
2223
* [ST_INTERSECTS](st-intersects.md)
2324
* [ST_ISVALID](st-isvalid.md)
2425
* [ST_ISVALIDDETAILED](st-isvaliddetailed.md)
2526
* [ST_WITHIN](st-within.md)
2627

27-
28-
29-
30-
31-
3228
## Next steps
3329

3430
- [System functions Azure Cosmos DB](system-functions.md)
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
title: ST_AREA in Azure Cosmos DB query language
3+
description: Learn about SQL system function ST_AREA in Azure Cosmos DB.
4+
author: jcocchi
5+
ms.service: cosmos-db
6+
ms.subservice: nosql
7+
ms.topic: conceptual
8+
ms.date: 10/21/2022
9+
ms.author: jucocchi
10+
ms.custom: query-reference, ignite-2022
11+
---
12+
13+
# ST_AREA (Azure Cosmos DB)
14+
15+
[!INCLUDE[NoSQL](../../includes/appliesto-nosql.md)]
16+
17+
Returns the total area of a GeoJSON Polygon or MultiPolygon expression. To learn more, see the [Geospatial and GeoJSON location data](geospatial-intro.md) article.
18+
19+
## Syntax
20+
21+
```sql
22+
ST_AREA (<spatial_expr>)
23+
```
24+
25+
## Arguments
26+
27+
*spatial_expr*
28+
Is any valid GeoJSON Polygon or MultiPolygon object expression.
29+
30+
## Return types
31+
32+
Returns the total area of a set of points. This is expressed in square meters for the default reference system.
33+
34+
## Examples
35+
36+
The following example shows how to return the area of a polygon using the `ST_AREA` built-in function.
37+
38+
```sql
39+
SELECT ST_AREA({
40+
"type":"Polygon",
41+
"coordinates":[ [
42+
[ 31.8, -5 ],
43+
[ 32, -5 ],
44+
[ 32, -4.7 ],
45+
[ 31.8, -4.7 ],
46+
[ 31.8, -5 ]
47+
] ]
48+
}) as Area
49+
```
50+
51+
Here is the result set.
52+
53+
```json
54+
[
55+
{
56+
"Area": 735970283.0522614
57+
}
58+
]
59+
```
60+
61+
## Remarks
62+
63+
Using the ST_AREA function to calculate the area of zero or one-dimensional figures like GeoJSON Points and LineStrings will result in an area of 0.
64+
65+
> [!NOTE]
66+
> The GeoJSON specification requires that points within a Polygon be specified in counter-clockwise order. A Polygon specified in clockwise order represents the inverse of the region within it.
67+
68+
## Next steps
69+
70+
- [Spatial functions Azure Cosmos DB](spatial-functions.md)
71+
- [System functions Azure Cosmos DB](system-functions.md)
72+
- [Introduction to Azure Cosmos DB](../../introduction.md)

articles/cosmos-db/nosql/query/st-distance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ST_DISTANCE (<spatial_expr>, <spatial_expr>)
3131

3232
## Examples
3333

34-
The following example shows how to return all family documents that are within 30 km of the specified location using the `ST_DISTANCE` built-in function. .
34+
The following example shows how to return all family documents that are within 30 km of the specified location using the `ST_DISTANCE` built-in function.
3535

3636
```sql
3737
SELECT f.id

0 commit comments

Comments
 (0)