[MarkLogic Dev General] xdmp:collection-delete()

Geert Josten geert.josten at dayon.nl
Wed Mar 7 22:39:22 PST 2012


Hi Palani,



Ah, yes. URI lexicon can return directories too. Funny that
xdmp:document-set-collections allows adding directories to collections..



Kind regards,

Geert



*Van:* general-bounces at developer.marklogic.com [mailto:
general-bounces at developer.marklogic.com] *Namens *Palani TT
*Verzonden:* woensdag 7 maart 2012 22:10
*Aan:* MarkLogic Developer Discussion
*Onderwerp:* Re: [MarkLogic Dev General] xdmp:collection-delete()



Hi Geert,



Yes, I did verify the count of the the collection "Test" using
count(fn:collection("Test")) and it was 50.



Below is the code that I was using to move the doc uris to "Test"
collection,



let $result := for $i in cts:uri-match("/localhost/userid/*")[1 to 51]

             let $insert-collections:= xdmp:document-set-collections($i,
"Test")

              return $insert-collections



return "success"



Since, I used the cts:uri-match(), the first doc uri that gets set in the
"Test" collection will be "/localhost/userid/" and this was the reason for
deletion of all the records under that folder when I tried to do
xdmp:collection-delete().



Thanks for extending your help!



Regards,

Palani







Thanks,

Palani

On Wed, Mar 7, 2012 at 3:14 PM, Geert Josten <geert.josten at dayon.nl> wrote:

Hi Palani,



Sure only 50 docs had been added to that collection? You can test that
easily using count(collection(“Test”)), or for a bit more speed
xdmp:estimate(collection(“Test”))



Kind regards,

Geert



*Van:* general-bounces at developer.marklogic.com [mailto:general-bounces at deve
loper.marklogic.com] *Namens *Palani TT
*Verzonden:* woensdag 7 maart 2012 20:10
*Aan:* general at developer.marklogic.com
*Onderwerp:* [MarkLogic Dev General] xdmp:collection-delete()



Hi,



I am trying to understand the behavior of this function. My requirement was
to delete the records in a particular collection. I had like 2000 records
under a particular userid/folder. I moved 50 records from that userid to a
collection named "Test" using xdmp:document-set-collections() function.
After that, I wanted to delete the collection "Test" by invoking the
function xdmp:collection:delete(). What happened was all the 2000 records
under that particular userid/folder got deleted when I thought only the 50
records were supposed to get deleted. Can anyone please, explain this
behavior?



Thanks,

Palani


_______________________________________________
General mailing list
General at developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20120308/c4723229/attachment.html 


More information about the General mailing list