Projection state sorting, filtering, paging

Hi team.
Short question: Is it possible to sort the state of some projection then apply a filter by some field and split the result into the pages?

More details:
Requirements
Our imaginary system has User aggregate with events UserRegistered, UserJobTitleChanged.
Number of users can be for example 10k.
Customer wants to have an webpage with following grid:

It seems like this starts to be the case where you don’t serve queries directly from the event store, but instead from a dedicated read model, such as a relational database, which should be able to handle 10k users easily.

Hi,

As Sebastian says, at the moment this is likely something you’d do outside the event store.

Cheers,

James

fromAll().when({$any : ``handle123, $stateQueryingEngine: {provider: "EventStore.Projections.```StateQuerying.MongoDb`````QueryingEngine``", idSelector: "id", anotherConfigItem: "123"}`` }); ``

Hi,

As Sebastian says, at the moment this is likely something you’d do outside the event store.

Cheers,

James

Sent from my iPhone

It seems like this starts to be the case where you don’t serve queries directly from the event store, but instead from a dedicated read model, such as a relational database, which should be able to handle 10k users easily.

Hi team.

Short question: Is it possible to sort the state of some projection then apply a filter by some field and split the result into the pages?

More details:

Requirements

Our imaginary system has User aggregate with events UserRegistered, UserJobTitleChanged.

Number of users can be for example 10k.

Customer wants to have an webpage with following grid:

First Name | Last Name | Job Title |




The table should have pagination, sorting by each of 3 columns and filter by job title column. Grid will be displayed in a browser (even in IE8 :slight_smile: ) so all data can not be sorted/filtered/paged on a client side.

Solution

I don’t known right way. But the following solution is only one I can do: Build projection for each case and
get the state via ajax

mydomain.com/streams/userOrderByAscFirstName/state

mydomain.com/streams/userOrderByAscSecondName/state

mydomain.com/streams/userOrderByAscJobTitle/state

mydomain.com/streams/userOrderByDescFirstName/state

mydomain.com/streams/userOrderByFirstNamePage0_100/state

mydomain.com/streams/userOrderByFirstNamePage101_200/state

Can’t even imagine how to make filter by job title… For instance when users put “Prog” or just “pr” system should return all programers.

Please help.

Thanks.

You received this message because you are subscribed to the Google Groups “Event Store” group.

To unsubscribe from this group and stop receiving emails from it, send an email to
[email protected].

For more options, visit
https://groups.google.com/groups/opt_out
.


Sebastian Good

You received this message because you are subscribed to the Google Groups “Event Store” group.

To unsubscribe from this group and stop receiving emails from it, send an email to
[email protected].

For more options, visit https://groups.google.com/groups/opt_out.

Okey, I see.
By the way, it will be really great feature to query projection state via OData.
Just imagine, next query will work mydomain.com/streams/user/state?$filter=startswith(JobTitle, ‘prog’) eq true&$orderby=Last Name asc&$skip=200&$top=100
Underneath it can use some NoSql store only for querying, e.g. mongodb.
Do projection can be described like so:

People can choose predefined StateQueryingEngine or implement it itself.
Is it make sense?

This is really not what projections are for (you are trying to use them as a K-V store). Why not just use a KV/Document store as your read model at that point? You can pretty easily hook up fromt he outside using a CatchUpSubscription to write handlers to any other read model.

The main use cases of the projections library are two-fold. The first is small bit of reactive code to handle repartitioning etc of your event streams (such as indexing the following will create a stream per correlation id)

fromAll().when({$any : function(s,e) { linkTo(e.metadata.correlationId, e)});

The other main use case for them is a query model for handling temporal correlation queries (on the fly) with no or little previous indexing having been done.

The quintessential use case for this is in the health care industry and looking for clinical trial patients. I need to find patients that were diagnosed with disease D within the last year. I am then looking that they had treatment t1 and failed with a lab result that looked like lr1 within 6 weeks of starting that treatment. Within one month they then had to be given treatment t2 and failed that treatment within the last six months with a labresult that looks like lr2.

This kind of query projections does very very well (and there are few systems that are good at this query, how would it look in SQL?).

Cheers,

Greg

Native key value stores (e.g.: redis) should play really well with EventStore via event subscriptions. They will be more suitable than projections for various querying, filtering and paging scenarios. One just need to make sure that event pointer is saved either directly in the view or within the same transaction (e.g. lua script or server-side transaction in Redis).

SQL-like storage with it’s own query engine would even enable ad-hoc reporting.