Open luczsoma opened 3 years ago
@kushagraThapar PTAL
Considering this for next semester planning.
@TheovanKraay please take a look at this issue, thanks!
Hi @luczsoma, we deeply appreciate your input into this project. Regrettably, this issue has remained inactive for over 2 years, leading us to the decision to close it. We've implemented this policy to maintain the relevance of our issue queue and facilitate easier navigation for new contributors. If you still believe this topic requires attention, please feel free to create a new issue, referencing this one. Thank you for your understanding and ongoing support.
@luczsoma we discussed about this and the recommendation from spring team is to not include more custom methods in the spring data cosmos - CosmosRepository. I will recommend using the CosmosClient which gets created in spring data cosmos SDK under the hood and you should be able to use this API - readMany - https://learn.microsoft.com/en-us/java/api/com.azure.cosmos.cosmosasynccontainer?view=azure-java-stable#com-azure-cosmos-cosmosasynccontainer-(t)readmany(java-util-list(com-azure-cosmos-models-cosmositemidentity)-com-azure-cosmos-models-cosmosreadmanyrequestoptions-java-lang-class(t))
Is your feature request related to a problem? Please describe. Looking up or deleting multiple items with
CosmosRepository
(of azure-spring-data-cosmos) cannot be done without fan-out queries, in one step (as one query).Describe the solution you'd like
CosmosRepository
hasfindById
anddeleteById
overrides havingPartitionKey
as their 2nd parameter, enabling efficient, in-partition queries. There could befindAllById
anddeleteAllById
overrides as well with aPartitionKey
parameters, enabling lookups/deletes of multiple items within one partition, e.g.:The method
findAllById(Iterable<ID> ids, PartitionKey pk)
would initiate afindAllById
search, but only within the partition specified bypk
, and return the found items. If no items were found with the givenids
in the partition specified bypk
, the returned list would be empty. If no partition exists with the keypk
, the returned list would be empty. (Implicitly, if an item with the specified ID can not be found in the given partition, but can be found in another partition, the result will not contain the item.)Similarly, the method
deleteAllById(Iterable<ID> ids, PartitionKey pk)
would initiate adeleteAllById
, but only within the partition specified bypk
. If no items were found with the givenids
in the partition specified bypk
, the method would return regularly. If no partition exists with the keypk
, the method would return regularly. (Implicitly, if an item with the specified ID can not be found in the given partition, but can be found in another partition, it won't be deleted.)Describe alternatives you've considered The alternatives for solving the multi-lookup problem are either calling
findAllById(Iterable<ID> ids)
(but this is a fan-out query, which is AFAIK very inefficient in Cosmos), or callingfindById(ID id, PartitionKey pk)
multiple times. Both solutions are inefficient. The same problem exists for deleting.Additional context —
Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report