There are many ideas on how to generate URI’s. If you can generate them from a combination of values in your document which should be unique, That way this enforces the equivalent of a unique key.
Many designs do not rely on any “special” uri … that is any URI will do because you are searching the contents of the document Not looking it up by its URI. In that case xdmp:random() is your friend let $uri := "/mystuff/" || xdmp:random() || ".xml" return $uri If you are worried about duplicate URI’s from the random number, (not going to happen in your lifetime) , There is a mail about this from Wayne http://markmail.org/message/mm5vtacpdzwfy44j ----------------------------------------------------------------------------- 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]] On Behalf Of Guoliang Li Sent: Wednesday, November 20, 2013 3:21 AM To: MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] Update: replace vs insert Thanks Mike. Seems there's no big difference between this two query. I got this from dev guide: "in the case of modifying a document, MarkLogic server creats new versions of the fragments ivolved in the opperation." So, I'll treat document as row of table, and the primary key will be the URI, right? However, I cannot find a perfect way to generate the URI, any suggestions? Thanks. Regards, GL On Nov 20, 2013 12:20 PM, "Michael Blakeley" <[email protected]<mailto:[email protected]>> wrote: Broadly speaking there isn't much difference. Functions for node-level update are mostly just a convenience for developers. Internally, both end up doing much the same thing. An update writes an entire XML tree, plus the term-list entries for any relevant indexes. That might sound inefficient if you are thinking about documents as tables. But in most cases documents act more like rows. Try to design that way, with a primary key as the document URI. -- Mike On 19 Nov 2013, at 19:36 , Guoliang Li <[email protected]<mailto:[email protected]>> wrote: > Hi all, > > I'm totally new to MarkLogic. > I know i can update a field by node-replace or document-insert. > May i know the difference in term of poformance? Thanks. > > Btw, Our app will keep all history data. > > Regards, > GL > > _______________________________________________ > General mailing list > [email protected]<mailto:[email protected]> > http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected]<mailto:[email protected]> http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
