Filtering for items in streams

+2 votes
I currently have streams where one key is the year an item was recorded (keys run from 2008-2020). Is it possible to list the items in the stream where key e.g.  > 2010 i.e. to do some filtering of stream items based on key values.


Second question - is it possible to create substreams within a stream. Some of the data i am adding has a hierarchical structure so i would like to represent that in substreams.


Thanks a lot!
asked Feb 9, 2022 by anonymous

1 Answer

+1 vote

You can list items with a specific key using the liststreamkeyitems command, but this doesn't allow a numerical range or set of options to be passed. If you want more advanced querying, you may want to consider using MultiChain Enterprise (whose free demo runs for the first 3 months of a chain), which can update an external database in realtime based on the content of a stream. The open source MultiChain Feed Adapter comes with built-in support for PostgreSQL, MySQL/MariaDB and MongoDB.

As for sub-streams, there isn't a mechanism for that. But you can use keys to tag items into something which effectively works as a sub-stream, containing all the items with that key.

answered Feb 9, 2022 by MultiChain