1000 XML files should move fairly easily using a simple XQuery script (assuming
they are not huge). Much more than that and you may have to break up the list
into smaller chunks.
I suggest trying to use eval like this
( roughly off my head NOT tested)
This may not be the most efficient way to do this, but it should give you a
start
---------------------------------------------------------------------------------------------
for $d in doc()
return
xdmp:eval(
"declare variable $doc external;
declare variable $newuri external ;
xdmp:document-insert(xdmp:document-insert(
$newuri,
$doc
)
" ,
( "doc" , $d , "newuri" , xdmp:node-uri($d) ) ,
<options xmlns="xdmp:eval">
<database>{xdmp:database("otherdb")}</database>
</options> )
-----------------------------------------------------------------------------
David Lee
Lead Engineer
MarkLogic Corporation
[email protected]
Phone: +1 812-482-5224
Cell: +1 812-630-7622
www.marklogic.com<http://www.marklogic.com/>
From: [email protected]
[mailto:[email protected]] On Behalf Of Singh, Gurbeer
Sent: Monday, February 11, 2013 5:30 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] How to move content from one data base
toanother
We need to write a JOB which will run over night and fetch close to 1000 XML
from one source and move it to another data base
I was planning to write one XQY for this and scheduled it daily.
XQY will run in Source DB and move to destination data-base .
~Gurbeer
From: [email protected]
[mailto:[email protected]] On Behalf Of David Lee
Sent: Monday, February 11, 2013 5:22 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] How to move content from one data base
toanother
How many documents are you dealing with ?
That would give us a better idea of what technique to suggest.
If it's just a few hundred or less than a quick script in QC is easy, and
Nelson's suggestion should work fine.
If its thousands millions or more than something more powerful is called for.
Also is this a repetitive task or one-off ?
-----------------------------------------------------------------------------
David Lee
Lead Engineer
MarkLogic Corporation
[email protected]<mailto:[email protected]>
Phone: +1 812-482-5224
Cell: +1 812-630-7622
www.marklogic.com<http://www.marklogic.com/>
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Nelson Wells
Sent: Monday, February 11, 2013 5:13 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] How to move content from one data base
toanother
Hi Gurbeer,
If you really want to do these operations through the query console, you can
use xdmp:eval (http://docs.marklogic.com/xdmp:eval) to specify a database other
than your context DB. I think Geert's suggestions are going to be more robust
and scalable, though.
Nelson Wells
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Singh, Gurbeer
Sent: Monday, February 11, 2013 4:05 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] How to move content from one data base
toanother
I didn't get it,
I am In CQ (Source database), I got the URI which I need to move , I created a
variable
Let $doc:= fn:doc($uri)
Now I need to save this $doc to destination data base , how I can connect to
destination data-base when I am in source data-base.
One way looks to me, write some .net/Java code call XQRY to source data-base,
get the result and dump it to destination data-base
I tried something like this
xdmp:document-insert(
$newuri,
$doc,
xdmp:default-permissions(),
xdmp:default-collections(),
0,
11130048076528179319
)
Getting error
Specified forest 11130048076528179319 not in database
Which is true. Any other suggestion.
~Gurbeer
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Tim Meagher
Sent: Monday, February 11, 2013 4:33 PM
To: 'MarkLogic Developer Discussion'
Subject: Re: [MarkLogic Dev General] How to move content from one data base
toanother
What I did was to create a xdmp:get utility that 1st acquires the list of URIs
that I want to extract from the source database - note that I have custom code
on the source server which reads request fields to determine exactly what
content to return. Next I iteratively spawn a utility that invokes a transform
on the source server and returns the resulting document that I then insert
using xdmp:document-insert to the local database.
Tim
________________________________
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Singh, Gurbeer
Sent: Monday, February 11, 2013 2:18 PM
To: [email protected]<mailto:[email protected]>
Subject: [MarkLogic Dev General] How to move content from one data base
toanother
Hi,
We have created two Database under a ML instance.
Now we have to move some content from one data base to another , before moving
we need to do apply some logic.
I was wondering how can use xdmp:document-insert for this approach.
~Gurbeer
________________________________
NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or
views contained herein are not intended to be, and do not constitute, advice
within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and
Consumer Protection Act. If you have received this communication in error,
please destroy all electronic and paper copies and notify the sender
immediately. Mistransmission is not intended to waive confidentiality or
privilege. Morgan Stanley reserves the right, to the extent permitted under
applicable law, to monitor electronic communications. This message is subject
to terms available at the following link:
http://www.morganstanley.com/disclaimers If you cannot access these links,
please notify us by reply message and we will send the contents to you. By
messaging with Morgan Stanley you consent to the foregoing.
________________________________
NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or
views contained herein are not intended to be, and do not constitute, advice
within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and
Consumer Protection Act. If you have received this communication in error,
please destroy all electronic and paper copies and notify the sender
immediately. Mistransmission is not intended to waive confidentiality or
privilege. Morgan Stanley reserves the right, to the extent permitted under
applicable law, to monitor electronic communications. This message is subject
to terms available at the following link:
http://www.morganstanley.com/disclaimers If you cannot access these links,
please notify us by reply message and we will send the contents to you. By
messaging with Morgan Stanley you consent to the foregoing.
NOTICE OF CONFIDENTIALITY: This electronic message, including attachments, is
for the sole use of the named recipient and may contain confidential or
privileged information protected by State of Tennessee and Federal regulations.
Any unauthorized review, use, disclosure, copying or distribution is strictly
prohibited. If you are not the intended recipient or have received this
communication in error please contact the sender or email
[email protected]<mailto:[email protected]> and destroy all copies
of the original message. Thank you.
________________________________
NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or
views contained herein are not intended to be, and do not constitute, advice
within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and
Consumer Protection Act. If you have received this communication in error,
please destroy all electronic and paper copies and notify the sender
immediately. Mistransmission is not intended to waive confidentiality or
privilege. Morgan Stanley reserves the right, to the extent permitted under
applicable law, to monitor electronic communications. This message is subject
to terms available at the following link:
http://www.morganstanley.com/disclaimers If you cannot access these links,
please notify us by reply message and we will send the contents to you. By
messaging with Morgan Stanley you consent to the foregoing.
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general