1
votes

Suppose I have a "Employee" container with Partition Key as the "EmployeeId". What is the best way to query multiple employee items from this data store? I am using the .Net SDK V3 of Azure Cosmos Db

The option I could think of is -

Using ARRAY_CONTAINS() - link

Select * FROM Employee e where ARRAY_CONTAINS(@EmployeesIdList, e.EmployeeId)

This query will still be a cross-partitioned query. Also as per this, cross partition queries are enabled by default in the V3 sdk. So is this the correct way to query multiple such items?

1
Can you be a little more specific about what you are trying to achieve? Are you trying to pull all documents in the collection, or all documents with a specific EmployeeId, or all documents with one of a defined set of EmployeeId values? Also, can you post a sample document. - Paul
Use in clause or partition feature to fetch records. Partitions are logical separation in Cosmos DB and are well used for many purposes, one you have mentioned above. - Rahul Jha

1 Answers

0
votes

You can use IN operator in Azure Cosmos DB to include multiple values and pull data.

https://i.stack.imgur.com/rm813.png