I have experience working with SQL and am familiar with performing set differences using SQL. Although I understand that Elasticsearch (ES) operates differently, I believe there must be an efficient method for achieving a set difference of two indices in ES. To clarify my question, let's consider the scenario where index A contains all elements within a certain universe, and index B consists of only specific elements from A. Essentially, every element x in B also exists in A.

Given this, I am seeking a way to calculate the difference between A and B, meaning identifying elements in A that do not exist in B. Despite my efforts to find a solution, it seems challenging to achieve this in ES. This is concerning as excluding elements is a common operation in my use case, where A contains millions of records while B is a much smaller subset of A. It is crucial for me to accurately count the number of excluded elements in my logic. Appreciate any kind of help that might be provided.