Hi Vikas,
as an alternative, you could reconsider your search strategy. Instead of searching through events, our projects usually provide raw search data (= searchable tokens, source entity (etc.) type, IDs) as a projection. While this is a bit more overhead compared to searching inside the events, it is quite flexible and does not couple to a specific kind of event store. Actually, it allows to integrate searchable data from sources with many different kinds of implementation pattern, beyond event sourced modules.
If you should do so, then as a starter, the following pattern (so far) worked like a charm for us with respect to event sourcing and gdpr:
All potentially relevant data ist encrpyted in the events using symmetric, salted encryption. This includes practically any kind of text fields, but also practically any references connecting information regarding a person with other entities*. The key is stored in a CRUD accessible database.
The index to that key (key to the key) is the ID of the entity which governs the lifetime of the data. That might be something connected to a real person, then the lifetime depends on the GDPR limited need-to-store-the-data, and makes this data available for information requests and deletion requests by a human being. That might also be the ID of a contract or account, then the lifetime is connected to the requirements regarding orderly book and record keeping.
There is a specific generic data type for protected information, that has an accessor returning an option type.
The index itself is also stored with the encrpyted data, so that the reading part of the system does not need to know the details of the above scheme.
When reading into memory (i.e. during projection or transaction preparation), the data is automatically decrypted, if the key is no longer known, it returns None. Subsequent projections usually replace that None with token strings like 'removed do to GDPR request or end of record keeping period'.
Writing into a data cell without key registered leads to generation of a new key.
Deletation is effected by removing the key.
The key database itself is encrypted using a run-time configurable key, so the database is automatically anonymized without the secret.
* Two caveats:
- the entity reference structure must be designed with GDPR in mind. It took some thinking to get the right references connected to the right keys such that deletion requests and record keeping requirements were correctly respected. Amazingly, no conflict between them occurred.
- since the key index is stored in immutable data, tracing it thoughout the database forms a network potentially allowing to stil recover information allowing to identify a person. This takes some thinking to get right.
Also, I did not have this design audited yet, but from previous audit experience, I assume (=hope) that it would pass.
Cheers
Phil