I saved a bunch of content in MarkLogic as binary format documents instead of XML. When I decode the document, it's XML. The side-effect of this error is that my searches don't include those documents.
Is there a way to convert the format of a document in-situ? If not, is there a way to do some kind of mass conversion? Any other ideas on how I can resolve this?
I know how to list all the URIs for binary documents:
xquery version "1.0-ml";
declare namespace qry = "http://marklogic.com/cts/query";
let $binary-term :=
xdmp:plan(/binary())//qry:term-query/qry:key/text()
let $binary_uris := cts:uris((), (), cts:term-query($binary-term))
return $binary_uris
and I know how to decode the documents:
xdmp:binary-decode(fn:doc($uri)/node(), "UTF-8")
but what I don't know is what to do after that. I can loop over that list of $binary_uris and decode them, but how do I take that result and overwrite the existing document in a batch process?