Skip to content

Commit 4fb12e8

Browse files
committed
updated Invoke-CosmosQuery docs
1 parent 24a114f commit 4fb12e8

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

Commands/Public/Invoke-CosmosQuery.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function Invoke-CosmosQuery
3434
This command performs cross partition parametrized query and iteratively fetches all matching documents. Command also measures total RU consumption of the query
3535
3636
.EXAMPLE
37+
Connect-Cosmos -AccountName myCosmosDbAccount -Database myCosmosDb -UseManagedIdentity -CollectResponseHeaders
3738
$query = "select * from c where c.itemType = @itemType"
3839
$queryParams = @{
3940
'@itemType' = 'person'
@@ -43,13 +44,12 @@ function Invoke-CosmosQuery
4344
{
4445
$rsp.data.Documents
4546
"Total RU consumption: $($rsp | Measure-Object -Property Charge -Sum | select -ExpandProperty Sum)"
46-
"Total query time: $($rsp | select-object -expandProperty QueryMetrics | Measure-Object -Property TotalTime -Sum | select -ExpandProperty Sum)"
4747
}
4848
4949
Description
5050
-----------
5151
This command performs cross partition parametrized query, potentially iterating over all partition key ranges, and fetches all matching documents, automatically paginating over all pages.
52-
Command also measures total RU consumption and populates query metrics in the response and measures total query time across all subqueries
52+
Command also measures total RU consumption and populates 'x-ms-documentdb-query-metrics' header in the response across all subqueries
5353
#>
5454

5555
[CmdletBinding()]

Module/CosmosLite/CosmosLite.psm1

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,24 @@ function Invoke-CosmosQuery
564564
Description
565565
-----------
566566
This command performs cross partition parametrized query and iteratively fetches all matching documents. Command also measures total RU consumption of the query
567+
568+
.EXAMPLE
569+
Connect-Cosmos -AccountName myCosmosDbAccount -Database myCosmosDb -UseManagedIdentity -CollectResponseHeaders
570+
$query = "select * from c where c.itemType = @itemType"
571+
$queryParams = @{
572+
'@itemType' = 'person'
573+
}
574+
$rsp = Invoke-CosmosQuery -Query $query -QueryParameters $queryParams -Collection 'docs' -MaxItems 10 -AutoContinue -PopulateMetrics
575+
if($rsp.IsSuccess)
576+
{
577+
$rsp.data.Documents
578+
"Total RU consumption: $($rsp | Measure-Object -Property Charge -Sum | select -ExpandProperty Sum)"
579+
}
580+
581+
Description
582+
-----------
583+
This command performs cross partition parametrized query, potentially iterating over all partition key ranges, and fetches all matching documents, automatically paginating over all pages.
584+
Command also measures total RU consumption and populates 'x-ms-documentdb-query-metrics' header in the response across all subqueries
567585
#>
568586

569587
[CmdletBinding()]
@@ -617,8 +635,9 @@ function Invoke-CosmosQuery
617635
$PopulateMetrics,
618636

619637
[switch]
620-
#when response contains continuation token, returns the reesponse and automatically sends new request with continuation token
621-
#this simnlifies getting all data from query for large datasets
638+
#when response contains continuation token, returns the response and automatically sends new request with continuation token
639+
#on large collection with multiple partitions, it also iterates over all partition key ranges and queries them one by one
640+
#this simplifies getting all data from query for large datasets
622641
$AutoContinue,
623642

624643
[Parameter()]

0 commit comments

Comments
 (0)