I have 2 indices, index1 and index2 each containing thousands of records. I am querying index1, getting 40k hits, then for each hit I need to query index2 which itself gives 10k hits each time. This way, I end up with a for loop with 40k iterations. Each iteration has a for loop with 10k iterations. Making a total of 40k * 10k=400000,000 iterations. As you can see this is a huge value and I have to wait for about 30 minutes for the results.
There surely must be a better way to implement this. May be a function I am not aware of or maybe a better design for such queries.
Any help would be appreciated!!