Skip to content

Commit b24490d

Browse files
committed
HPk and index metrics merge -remove mv doc
2 parents 86eff36 + 5a24cb4 commit b24490d

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

articles/cosmos-db/hierarchical-partition-keys.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,20 @@ const partitionKey: PartitionKey = new PartitionKeyBuilder()
395395
// Create the item in the container
396396
const { resource: document } = await container.items.create(item, partitionKey);
397397
```
398+
399+
#### [Python SDK](#tab/python)
400+
401+
For python, just make sure that values for all the fields in the partition key path are specified in the item definition.
402+
403+
```python
404+
# specify values for all fields on partition key path
405+
item_definition = {'id': 'f7da01b0-090b-41d2-8416-dacae09fbb4a',
406+
'tenantId': 'Microsoft',
407+
'userId': '8411f20f-be3e-416a-a3e7-dcd5a3c1f28b',
408+
'sessionId': '0000-11-0000-1111'}
409+
410+
item = container.create_item(body=item_definition)
411+
```
398412
---
399413

400414
### Perform a key/value lookup (point read) of an item

articles/cosmos-db/nosql/index-metrics.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ ms.reviewer: jucocchi
1414

1515
Azure Cosmos DB provides indexing metrics to show both utilized indexed paths and recommended indexed paths. You can use the indexing metrics to optimize query performance, especially in cases where you aren't sure how to modify the [indexing policy](../index-policy.md)).
1616

17-
> [!NOTE]
18-
> The indexing metrics are only supported in the .NET SDK (version 3.21.0 or later) and Java SDK (version 4.19.0 or later)
17+
## Supported SDK versions
18+
Indexing metrics are supported in the following SDK versions:
19+
| SDK | Supported versions |
20+
| --- | --- |
21+
| .NET SDK v3 | >= 3.21.0 |
22+
| Java SDK v4 | >= 4.19.0 |
23+
| Python SDK | >= 4.6.0 |
1924

2025
## Enable indexing metrics
2126

@@ -91,6 +96,17 @@ const { resources: resultsIndexMetrics, indexMetrics } = await container.items
9196
.fetchAll();
9297
console.log("IndexMetrics: ", indexMetrics);
9398
```
99+
100+
## [Python SDK](#tab/python)
101+
You can capture index metrics by passing in the populate_index_metrics keyword in query items and then reading the value for "x-ms-cosmos-index-utilization" header from the response. This header is returned only if the query returns some items.
102+
103+
```python
104+
query_items = container.query_items(query="Select * from c",
105+
enable_cross_partition_query=True,
106+
populate_index_metrics=True)
107+
108+
print(container.client_connection.last_response_headers['x-ms-cosmos-index-utilization'])
109+
```
94110
---
95111

96112
### Example output

0 commit comments

Comments
 (0)