jewzaam / go-cosmosdb

Apache License 2.0
6 stars 18 forks source link

rest call metadata #3

Open mjudeikis opened 4 years ago

mjudeikis commented 4 years ago

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}]}
  2. 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?

mjudeikis commented 4 years ago

More https://tsmatz.wordpress.com/2016/12/07/azure-documentdb-and-mongodb-partitioning-replication-indexing/

mjudeikis commented 4 years ago

this client supports only gateway queries: https://docs.microsoft.com/en-us/rest/api/cosmos-db/querying-cosmosdb-resources-using-the-rest-api#queries-that-cannot-be-served-by-gateway