Search code examples
c#.netdomain-driven-designeventstoredb

Searching for a stream in EventStore


Is it possible to search for a stream not by StreamId but by some another Stream attribute? For example, if every stream has CustomerId in the Headers and I would like to search for all the streams with the particular CustomerId.


Solution

  • Event stores are designed to support retrieval exclusively by the key of the entity. To support retrieval by other attributes, data is indexed in an eventually consistent, de-normalized fashion specifically for each use case and in a separate place. So the event-store only stores events and to support querying of any sort indexed projections are utilized. These are sort of like persistent views in a relational database but they can be stored in a simple key-value store. Together, an event-store and a projection store constitute part of the infrastructure behind a CQRS + Event Sourcing architecture. Take a look here and the rest of that blog for more on this subject.