David Satorres · Dec 17, 2021

IRIS as a document database and Properties population

Hello all,

I'm "playing" a little bit with IRIS as document database, as it seems really simple to use.

So far, creating a database and inserting documents is fine. Creating a Property so it can be indexed seems very useful and it works well when this property is created at the very beginning. But here my "problem": whenever a new property is added, how can the values be recalculated and inserted, so indices can be correctly updated? 

So far, I've only found as a solution opening and saving the documents :'( This is ok for a POC, but what when millions of documents are stored?

Product version: IRIS 2021.1
0 113
Discussion (3)1
Log in or sign up to continue

Properties are recalculated so it's enough to execute this query once:

UPDATE <DOC TABLE CLASS> SET %Doc = NVL(%Doc||' ', %Doc)

I'm not sure how to trick SQL engine into updating the value without changing it completely but just NVL(%Doc, %Doc) does not work. Adding empty space after json does not affect it.

For DocDB indexed properties are defined as

Property firstName As %String [ SqlComputeCode = { set {*}=$$%EvaluatePathOne^%DocDB.Document({%Doc},"$.firstName")}, SqlComputed, SqlComputeOnChange = %Doc ];

So updating %Doc does the trick.

Also add:


to recalculate only for documents where a property value is missing.

Hi Eduard,

This is basically same approach as mine, but straight with one single SQL operation.

Even if it works (it does, I've tested), in a database with potentially millions of records it seems to me that we would be missing background and multi-thread capacities. But by looking at the documentation I've been unable to find any method for that purpose.

Thanks for the answer, anyway! :-)