I’m working on a MarkLogic Data Hub project and encountering issues when trying to add generated envelope documents to a collection (dita-envelope
) during a custom step in an ingestion flow.
.ditamap
files and create envelope documents.dita-envelope
collection in the staging database.xdmp.documentAddCollections
if (cts.docAvailable(envelopeUri)) {
xdmp.documentAddCollections(envelopeUri, ["dita-envelope"]);
}
Issue: Throws XDMP-OWNTXN errors because declareUpdate() is not allowed within the managed transaction context of a Data Hub custom step and without it gives error that declareUpdate is missing.
flowUtils.writeContentArray
const outputContent = {
uri: envelopeUri,
value: envelope,
context: {
metadata: {
collections: ["dita-envelope"],
},
},
};
flowUtils.writeContentArray([outputContent], options.database);
Issue: While the document gets written to the database, it is not assigned to the dita-envelope collection, only adds the metadata to the envelope.
addMetadataToContent
from flow-utils.mjs
flowUtils.addMetadataToContent(outputContent, flowName, stepName, jobId);
flowUtils.writeContentArray([outputContent], options.database);
Issue: Adds metadata to the file about the collection but doesn’t actually assign the document to the collection.
const placeholderUri = "/placeholder.json";
xdmp.documentInsert(placeholderUri, {}, {collections: ["dita-envelope"]});
Issue: Successfully creates the collection but doesn’t assign the envelope documents to it.
MarkLogic Version: 11.0 Data Hub Version: 6.1.1 Database Context: Using staging and final databases as part of the ingestion flow.
Any guidance or suggestions for best practices to achieve this would be greatly appreciated!
Shouldn't the collections
be a child of the context
and sibling to the metadata
in the content object?
const outputContent = {
uri: envelopeUri,
value: envelope,
context: {
metadata: {},
collections: ["dita-envelope"]
}
};