Thursday, April 12, 2012

MARKLOGIC:Load Files to Marklogic Server By using info:load


Load Files to Marklogic Server By using info:load

·        
Execute the Following Query,

xquery version "1.0-ml";
import module namespace info = "http://marklogic.com/appservices/infostudio" 
at "/MarkLogic/appservices/infostudio/info.xqy";
let $delta :=  <options xmlns="http://marklogic.com/appservices/infostudio">
                                 <collection>/test</collection>
                                 <uri>
<literal>/mydir/</literal>
                                                <filename/>
                                                <literal>.</literal>
                                                 <ext/>
                                </uri>
                        </options>
return  info:load("C:\TestFolder", (), $delta, "test")

·         In above query “C:\TestFolder” is the local uri which contains XML files, "test" is the Database Name and we can provide Our own collection like “<collection>/test</collection>
·         Now all of your Documents has 2 collections

o   /tickets/ticket/########### (Built-in collection added by info api)
o   /test (User defined collection)

·         If you want to remove Ticket collection use xdmp: document-remove-collections(“Document-name”,”/tickets/ticket/###########”)
·         If you have multiple documents you have implement above step in loop. For Example,

for $each in xdmp:directory("/mydir/","infinity")
return
          xdmp:document-remove-collections ( fn:base-uri($each),"/tickets/ticket/###")





No comments:

Post a Comment