I have an XQuery function which I am using to install a CPF pipeline programatically. I am testing this by executing the function call from the Query console, where my content source is set to the content db which has CPF enabled.
I was executing the following to troubleshoot what is going on. $processsed_pipline_config contains the pipeline config XML. The return returns only the pipeline that was inserted, so it looks to me like the pipeline is being inserted into a db that only has a single pipeline?
let $pipeline_id := p:insert($processed_pipeline_config)
return
for $pipeline in p:pipelines()
return $pipeline
When I go to the admin console, this inserted pipeline does not show up in the pipeline list for the content db.
Update
I also tried to invoke it in the context of the schema db, as suggested below. No luck either.
let $pipeline_id :=
xdmp:invoke-function(
function() {
p:insert($processed_pipeline_config)
},
<options xmlns="xdmp:eval">
<database>{ xdmp:schema-database() }</database>
<transaction-mode>update-auto-commit</transaction-mode>
<isolation>different-transaction</isolation>
</options>
)
The solution is that the p:insert() call should be made against the triggers database, rather than content or schema. Essentially:
xdmp:invoke-function(
function() {
p:insert($processed_pipeline_config)
},
<options xmlns="xdmp:eval">
<database>{ xdmp:triggers-database() }</database>
<transaction-mode>update-auto-commit</transaction-mode>
<isolation>different-transaction</isolation>
</options>
)
After doing this, the pipeline showed up in the list in the Admin console.