But this won't change any thing : doing query.list() will still load all the results in memory..
I didn't check how it works inside, but what I can see that this sample uses a reference to cache and then goes through keys using stream... Probably I am wrong and didn't catch what did you mean
Unfortunately Indexing itself doesn't have a way to delete entries that map to a specific index, without iterating as you have done. If your query returns too many results, you have to use `maxResults` and retrieve them in batches.
The other option is if you can do it is to use distributed streams that Vladimir is referencing. Unfortunately, what you need to do isn't supported as a direct API in a remote cache. Instead you need to use a ServerTask that invokes distributed streams. Once you are in a ServerTask you can do something like I mentioned in How to delete all entries whose values satisfy certain condition
If you need more information on ServerTask you can take a look at Infinispan 9.4 User Guide