Experimenting with Projections

The web UI isn’t very useful right now when experimenting with projections, and experimentation is the only way I can learn given the lack of documentation.

Is there any way to see all the partitions from a given projection?

Is there a way to force a projection to re-populate itself?

Alternatively, is there a way to delete a projection? I tried sending an ajax request through jquery but it said the DELETE verb wasn’t supported.

What are the differences between the types of projections?

Thanks :slight_smile:

Brian,

see comments below.

-yuriy

The web UI isn’t very useful right now when experimenting with projections, and experimentation is the only way I can learn given the lack of documentation.

Is there any way to see all the partitions from a given projection?

  • actually no easy way except reading $streams stream

Is there a way to force a projection to re-populate itself?

  • For non continuous/persistent projections any change to the projection definition just restarts it. However, for projections emitting other events it is more complicated. Projections write events to streams with names derived from the projection name, Therefore there is no simple way to remove these streams and start over. For the debugging purposes when recreating DB is not an option, I’d suggest to use options({}) statement which allows to override output stream name.

options({

$forceProjectionName: ‘new-name’

});

makes the projection to behave as it were named ‘new-name’. so, by changing this name you get it restarted with new stream names. (This is not intended to be used in production).

Alternatively, is there a way to delete a projection? I tried sending an ajax request through jquery but it said the DELETE verb wasn’t supported.

The ‘dev’ branch already support DELETE (to be merged soon), but it is still quite limited. the ‘delete’ operation does not delete any output streams yet. But, as we do not support deleting streams without leaving any trace in DB it will not help much anyway.

What are the differences between the types of projections?

(This naming may change to reflect projection behavior better)

  • one-time – runs once until end-of-transaction-file/then stop/then remove from memory on timeout

  • ad-hoc – runs in memory until the node is restarted (nothing is written to any stream/data are available via http only)

  • continuous – runs cross node restarts; definition is stored in the system stream; automatically restarts on node restart from the last checkpoint; automatically writes checkpoints to the system stream; state is available via http;

  • persistent – the same as continuous, but: on any state change emits StateUpdated event to the $projections-{name}-state stream (configurable) and support emit()/linkTo() statements; state is available via http and from the $projections-{name}-state

foreachStream() projections are only supported in persistent mode and they maintain multiple -state streams: $projections-{name}-{streamname}–state

This helps too. Thanks again. :slight_smile:

You have to be careful as well projections in the ES are quite
different than what most people are currently doing with projections.
They are more of stream querying than say OLAP. There will shortly be
more docs coming out (quite a few) on projections.