Can you search stream items' content?

+2 votes
I hope I am using streams in the right way here, so let me explain.

I am hoping to use streams as a time-stamped general purpose database. I am adding JSON objects as stream items with a GUID as the key. For example

{ "1dfd97f0-ff20-46ae-a72f-d8b3936ae167": { type: "Book"

                                                                        "name" : "Harry Potter"

                                                                        "author": "JK Rowling" }

etc... }


Is there a way of searching the JSON objects of the stream items by the JSON object's key i.e. I want to return books which are called "Harry Potter"?
asked Mar 2, 2018 by charlieasmith96

1 Answer

0 votes
Best answer

MultiChain doesn't currently support searching of stream item fields in this way. Your best workaround is to use MultiChain 2.0 alpha, which allows stream items to have multiple keys. You can then put any data you want to be searchable in a key, rather than in the payload. So in your example the item might have four keys:

name:Harry Potter
author:JK Rowling

Then you can use liststreamkeyitems with any of these keys to retrieve the full item.

answered Mar 2, 2018 by MultiChain
selected Mar 8, 2018 by charlieasmith96