Hi Rob,

Yes this works (I tested it to make sure). It automatically filters out 
delete-only forests from the xdmp:database-forests() lists, when doing the 
document-insert.

And also quite nice: it migrates custom document properties as well. :-)

Kind regards,
Geert

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of 
> Whitby, Rob, CMG
> Sent: maandag 2 november 2009 15:57
> To: General Mark Logic Developer Discussion
> Subject: RE: [MarkLogic Dev General] Moving documents from 
> one forest toanother
> 
> Ok thanks Geert. Here's the code:
> 
> xquery version '1.0-ml';
> 
> declare function local:document-move-forest($uri as xs:string) {
>       local:document-move-forest($uri,
> xdmp:database-forests(xdmp:database()))
> };
> 
> declare function local:document-move-forest($uri as 
> xs:string, $forest-ids as xs:unsignedLong*) {
>       xdmp:document-insert(
>               $uri,
>               fn:doc($uri),
>               xdmp:document-get-permissions($uri),
>               xdmp:document-get-collections($uri),
>               xdmp:document-get-quality($uri),
>               $forest-ids
>       )
> };
> 
>       
> 
> 
> 
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of 
> Geert Josten
> Sent: 02 November 2009 13:30
> To: General Mark Logic Developer Discussion
> Subject: RE: [MarkLogic Dev General] Moving documents from 
> one forest toanother
> 
> By the way,
> 
> It is quite easy to extend the function of Michael with a 
> second argument $forest-id, that you pass as last argument to 
> xdmp:document-insert. That effectively gives you your 
> move-to-forest function..
> 
> ;-)
> 
> Kind regards,
> Geert 
> 
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of Geert 
> > Josten
> > Sent: maandag 2 november 2009 14:20
> > To: General Mark Logic Developer Discussion
> > Subject: RE: [MarkLogic Dev General] Moving documents from 
> one forest 
> > toanother
> > 
> > Hi Rob,
> > 
> > Why are you against doing an update on the document? Too many 
> > documents? The documents in the old forest will have to be migrated 
> > any way, so that should not make much difference.
> > 
> > Michael Blakely once sent a function that essentially deletes and 
> > re-inserts the document on the same location, preserving 
> permissions 
> > and all. You can find it here:
> > 
> > http://markmail.org/message/2e5wu3sqgpiwnu5m
> > 
> > I thought you should be able to retrieve a list of all 
> documents in a 
> > specific forest, that should enable you to apply the update on the 
> > documents in the old forest only..
> > 
> > HTH,
> > Geert
> > 
> > >
> > 
> > 
> > Drs. G.P.H. Josten
> > Consultant
> > 
> > 
> > http://www.daidalos.nl/
> > Daidalos BV
> > Source of Innovation
> > Hoekeindsehof 1-4
> > 2665 JZ Bleiswijk
> > Tel.: +31 (0) 10 850 1200
> > Fax: +31 (0) 10 850 1199
> > http://www.daidalos.nl/
> > KvK 27164984
> > De informatie - verzonden in of met dit emailbericht - is afkomstig 
> > van Daidalos BV en is uitsluitend bestemd voor de geadresseerde. 
> > Indien u dit bericht onbedoeld hebt ontvangen, verzoeken 
> wij u het te 
> > verwijderen. Aan dit bericht kunnen geen rechten worden ontleend.
> > 
> > 
> > > From: [email protected]
> > > [mailto:[email protected]] On Behalf 
> > Of Whitby, 
> > > Rob, CMG
> > > Sent: maandag 2 november 2009 13:09
> > > To: General Mark Logic Developer Discussion
> > > Subject: RE: [MarkLogic Dev General] Moving documents from 
> > one forest 
> > > to another
> > >
> > > I just realized I won't have to delete the old docs after 
> an xqsync 
> > > because the uris will be the same it will in effect move 
> > them. Maybe 
> > > that's the best plan after all?
> > >
> > > Still would be handy to have something like 
> > > xdmp:document-move-forest($uri, $forest-ids)
> > >
> > > Rob
> > >
> > >
> > >
> > > -----Original Message-----
> > > From: [email protected]
> > > [mailto:[email protected]] On Behalf 
> > Of Whitby, 
> > > Rob, CMG
> > > Sent: 02 November 2009 11:34
> > > To: General Mark Logic Developer Discussion
> > > Subject: [MarkLogic Dev General] Moving documents from one 
> > forest to 
> > > another
> > >
> > > Hi
> > >
> > > I'm trying to work out the quickest way of moving documents 
> > from one 
> > > forest to another. In the admin guide it talks about making the 
> > > existing forest delete-only and then updating the 
> documents. I was 
> > > hoping to just add the docs to a collection to trigger the 
> > move, but 
> > > this function doesn't take forest-ids so errors. The only 
> > functions I 
> > > see are document-update and document-load which aren't really 
> > > suitable. Is there a trick I'm missing here?
> > >
> > > I also considered using xqsync but that seems like a pain 
> > because I'd 
> > > also have to delete the old documents.
> > >
> > > What's the best practice approach?
> > >
> > > Cheers
> > > Rob
> > >
> > >
> > > _______________________________________________
> > > General mailing list
> > > [email protected]
> > > http://xqzone.com/mailman/listinfo/general
> > > _______________________________________________
> > > General mailing list
> > > [email protected]
> > > http://xqzone.com/mailman/listinfo/general
> > >
> > 
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://xqzone.com/mailman/listinfo/general
> > _______________________________________________
> General mailing list
> [email protected]
> http://xqzone.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> [email protected]
> http://xqzone.com/mailman/listinfo/general
> _______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to