UPDATE myBucket AS d
SET d.parentClass = (FIRST p.id FOR p IN (SELECT d1.parentId , meta(d1).id, d1.locale, d1.language
FROM myBucket d1
WHERE d1._class = "secondaryClass" AND d1.hasChildren = true
AND d1.parentId LIKE "par%"`
)
WHEN d.parentId = p.parentId AND p.locale = d.locale AND p.language = d.language END)
WHERE d._class ="secondaryClass"
AND d.format IS NOT MISSING AND d.parentClass IS MISSING AND d.parentId LIKE "par%";
CREATE INDEX ix1 ON myBucket(parentId) WHERE _class ="secondaryClass" AND parentClass IS MISSING ;
CREATE INDEX ix2 ON myBucket(hasChildren, parentId, locale, language) WHERE _class ="secondaryClass";
CB 6.5
MERGE INTO myBucket AS m USING (SELECT d1.parentId, meta(d1).id, d1.locale, d1.language
FROM myBucket d1
WHERE d1._class = "secondaryClass"
AND d1.hasChildren = true
AND d1.parentId LIKE "par%" ) AS s
ON m.parentId = s.parentId AND m.locale = s.locale AND m.language = s.language
WHEN MATCHED THEN m.parentClass = s.id WHERE m.format IS NOT MISSING AND m.parentClass IS MISSING;