I'm not sure what feature of ElasticSearch to use for this, Analyzers? Aggregations? Something else?

I need to compare each indexed element with every other indexed element and calculate a score for how well they match each other. The calculation is based on the values of the terms in each indexed element. I can do the calculation part. I just don't know how to do the "looping" part.

I apologize if this has already been answered - I couldn't find what I was looking for.

Thank you.