[MarkLogic Dev General] Use Trigger to update conditionally a document
Kelly Stirman
Kelly.Stirman at marklogic.com
Fri Oct 1 07:31:40 PDT 2010
Salut Stephane,
What is the logic for determining that the document has not changed?
I think you could put the logic into your insert. Something like:
if(xdmp:exists(doc($uri))
then
if(xdmp:md5($new) ne xdmp:md5(doc($uri)))
then xdmp:document-insert($uri,$new-doc)
else ()
else xdmp:document-insert($uri,$new-doc)
That will slow down your loads, but it should be faster than using a trigger.
Kelly
Message: 3
Date: Fri, 1 Oct 2010 15:40:03 +0200
From: Stephane Toussaint <stephane.toussaint at 4dconcept.fr>
Subject: [MarkLogic Dev General] Use Trigger to update conditionally a
document
To: general at developer.marklogic.com
Message-ID: <6A818555-8BE5-4624-A85D-9190C445F4E4 at 4dconcept.fr>
Content-Type: text/plain; charset=iso-8859-1
Hi,
I try to achieve the following action :
I have a process where documents are inserted in marklogic in batch mode. Some document are reinserted without having change (Same uri and same content). I don't want those documents to have there last-modified property updated.
To do so I attempt to use pre-commit trigger to compare pre-action document content with the current update content.
But as a doc($trgr:uri) return the updated content, I'm not able to retrieve the old content.
Is there a way to do this ?
Is there any other solution in MarkLogic to do the same thing ?
Hope to be clear enough for you to give me some help.
Thanks
St?phane
More information about the General
mailing list