Query to insert new document from an existing document through named parameter

This approach I will follow:

CREATE INDEX ix1 ON default( META().id) WHERE  p_id IS MISSING;

Query :

SELECT RAW META(d).id 
FROM default AS d
WHERE  d.p_id IS MISSING AND META(p).id > $dockey LIMIT 10000;

Pick Any SDK:
          nextdockey  = ""
          Read the mapping into dictmap
          FOR loop for ever {
                     $dockey = nextdockey
                      Execute query with scan_consistency scan_plus
                      if query return no rows {
                                 break 
                      }
                      For each row  {
                                   nextdockey = value from the row
                                   do reactive API (may want to control number of concurrent reactive threads) {
                                         GET the document
                                         generate the new document and new document key from dictmap, old document
                                         INSERT the new document
                                  }
                       }
              }