Compare fields in two documents

I want to compare specific field of two documents in a single index. Based on my research the way to do this is to use scripting module. The script will evaluate if the fields are the same, something like this should do doc99['field_name'].value == doc100['field_name'].value.

Is this even possible?

The purpose is to only show document if specific field has changed comparing to the previous document and show on dashboard.

Thanks

Usually all actions (queries, filters, scripts) are used within one aggregate. It is not the preferred way to go to do a 'join'.