Hello Team,
I have cosmosdb setup for one of my requirements. The cosmosdb is accessed using its REST API functionality.
The cosmosdb is partitioned one key called let's cid. So overall the REST call looks like ,
https://{{DocumentDBHost}}/dbs/mydb/colls/mycol/docs/123
This works perfectly fine.
In the JSON document we also have few more fields/attributes like oid and sid.
Now we have an additional requirement that we want to query on multiple such ids. Suppose we have one attribute as oid (value 222) and one attribute as sid(333). If user uses any of these ids, the cosmosdb should return the JSON.
So essentially if user passes any of these
https://{{DocumentDBHost}}/dbs/mydb/colls/mycol/docs/123 //For cid
https://{{DocumentDBHost}}/dbs/mydb/colls/mycol/docs/222 //For oid
https://{{DocumentDBHost}}/dbs/mydb/colls/mycol/docs/333 //For sid
User wants this to get resolved internally. So if he passes any number as id, cosmosdb should search across these 3 type of ids ( attributes of JSON) and should be able to resolve it or find the correct document.
What's the best way to achieve it? Is there any way to have multiple partition keys at the same time which can resolve it?
Thanks,
Raja
Hello @AnuragSharma-MSFT
Thanks for the prompt response. Yes, I'm aware of the post requests, the only problem here is, it looks like a SQL query which might be little complex for end users to try with.
Okay, what if we create one more layer(other program/azure function/anything else?) in between which takes the id as input and then creates a post requests out of it as you have mentioned in your response.
Could you please suggest some good option of creating this "layer"?
Thanks for replying back. Yes we can create App service, Azure function etc. which will in turn call the Azure Cosmos DB rest apis.
We can choose the programming language which we are comfortable with while creating these services. Please let us know if there is any preference and guidance we need on the same.
Hello @AnuragSharma-MSFT ,
Thanks for the response. Can something like below be achieved with CosmosDB?
https://{ {DocumentDBHost}}/dbs/mydb/colls/mycol/docs/{Id}[?type]
Sign in to comment