jewzaam/go-cosmosdb

rest call metadata

Opened this issue · 2 comments

I suspect that request calls, currently done with the client does not represent real view:

  1. First call should be to /dbs/{database}/colls/{name}/docs
    with
x-ms-cosmos-is-query-plan-request: True

which will return something like this:

{"partitionedQueryExecutionInfoVersion":2,"queryInfo":{"distinctType":"None","top":null,"offset":null,"limit":null,"orderBy":[],"orderByExpressions":[],"groupByExpressions":[],"groupByAliases":[],"aggregates":["Count"],"groupByAliasToAggregateType":{},"rewrittenQuery":"SELECT VALUE [{\"item\": COUNT(1)}]\nFROM OpenShiftClusters AS doc\nWHERE ((NOT (doc.openShiftCluster.properties.provisioningState IN (\"Succeeded\", \"Failed\"))) AND ((doc.leaseExpires ?? 0) < (GetCurrentTimestamp() / 1000)))","hasSelectValue":true},"queryRanges":[{"min":"","max":"FF","isMinInclusive":true,"isMaxInclusive":false}]}
  1. Call should be to get app parition keys:
    GET to bs/{database}/colls/{name}/pkrange
    where it will return:
{"_rid":"JoEZANUS3lA=","PartitionKeyRanges":[{"_rid":"JoEZANUS3lACAAAAAAAAUA==","id":"0","_etag":"\"00007801-0000-0100-0000-5e0dbc4d0000\"","minInclusive":"","maxExclusive":"FF","ridPrefix":0,"_self":"dbs\/JoEZAA==\/colls\/JoEZANUS3lA=\/pkranges\/JoEZANUS3lACAAAAAAAAUA==\/","throughputFraction":1,"status":"online","parents":[],"_ts":1577958477}],"_count":1}

Where id:0 should be used as x-ms-documentdb-partitionkeyrangeid with the rewrittenQuery from 1st.

@jim-minter, ideas?