azure-sdk-for-java
azure-sdk-for-java copied to clipboard
[FEATURE REQ] PK-based findAllById + deleteAllById methods in CosmosRepository
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
has findById
and deleteById
overrides having PartitionKey
as their 2nd parameter, enabling efficient, in-partition queries. There could be findAllById
and deleteAllById
overrides as well with a PartitionKey
parameters, enabling lookups/deletes of multiple items within one partition, e.g.:
Iterable<T> findAllById(Iterable<ID> ids, PartitionKey pk);
void deleteAllById(Iterable<ID> ids, PartitionKey pk);
The method findAllById(Iterable<ID> ids, PartitionKey pk)
would initiate a findAllById
search, but only within the partition specified by pk
, and return the found items. If no items were found with the given ids
in the partition specified by pk
, the returned list would be empty. If no partition exists with the key pk
, 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 a deleteAllById
, but only within the partition specified by pk
. If no items were found with the given ids
in the partition specified by pk
, the method would return regularly. If no partition exists with the key pk
, 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 calling findById(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
- [x] Description Added
- [x] Expected solution specified
@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.