I don't know that I have any really generic way to check.  Some ideas: You 
could squirrel away something in a property when your code does an update 
(something like <changed>true</changed> ) or you could calculate an md5 or 
similar hash of the  content.   You might be able to do something more specific 
if you know exactly the type of changes being made to your content.

-Danny

From: [email protected] 
[mailto:[email protected]] On Behalf Of Tim
Sent: Wednesday, August 21, 2013 1:48 PM
To: 'MarkLogic Developer Discussion'
Subject: Re: [MarkLogic Dev General] Does adding a document to a collection 
trigger a CPF domain?

I hear you. BTW, how would you recommend checking for a change in content?

Tim

From: [email protected] 
[mailto:[email protected]] On Behalf Of Danny Sokolsky
Sent: Wednesday, August 21, 2013 4:17 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Does adding a document to a collection 
trigger a CPF domain?

Well, that is not quite how collections work.  A collection can technically 
exist without any documents belonging to it.  There is not really an entity of 
a collection; rather, it is a way to ask the database "show me all the 
documents that have this collection".  If there are no documents in that 
collection, then that query returns nothing.  Chris likes to describe it this 
way: "I have a collection of classic cars.  It just so happens that there are 
no cars in that collection."

I don't think that having the two sets of domains would work, because the CPF 
steps are triggered on updates, and in the case that you had documents in 2 
domains, both would fire and would give you overlapping domains, which is not 
desirable.

I think the safest way to deal with this is to add some logic to your pipeline 
actions to notice when the update did not actually change your content and skip 
the processing that assumes updated content.

-Danny

From: 
[email protected]<mailto:[email protected]>
 [mailto:[email protected]] On Behalf Of Tim
Sent: Wednesday, August 21, 2013 12:46 PM
To: 'MarkLogic Developer Discussion'
Subject: Re: [MarkLogic Dev General] Does adding a document to a collection 
trigger a CPF domain?

Hi Danny,

Thanks for the info.

While I understand that adding a collection updates a document, the domain 
configuration I used is based on the directory URI, not on collection.  In 
other words I think a document should belong to a collection, not a collection 
to a document.  So if a document is added to a collection for which a 
collection-based content processing domain exists, then it should trigger an 
update, but not if a collection is added to a document that is scoped in a 
directory URI-based content processing domain where no content is changed.  It 
is what it is and I got caught because I added the collection and it 
prematurely fired the update.  I did not think of the ramifications beforehand.

The only other suggestion I would have is that by separating an update between 
content and collection updates, it would effectively provide a means of 
defining separate collection-based and directory URI-based content processing 
domains without any overlap.  Adding a collection could then be a means of 
scoping a subset of documents for subsequent processing much like applying a 
relational database view without triggering any events.

Just something to think about...

Tim

From: 
[email protected]<mailto:[email protected]>
 [mailto:[email protected]] On Behalf Of Danny Sokolsky
Sent: Wednesday, August 21, 2013 2:20 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Does adding a document to a collection 
trigger a CPF domain?

Hi Tim,

Yes, adding a document to a collection would fire an update trigger because 
adding a collection is an update.

What you could do is have the updates that add a collection put the document 
into some state that, when triggered, would have an action that is a noop.

-Danny

From: 
[email protected]<mailto:[email protected]>
 [mailto:[email protected]] On Behalf Of Tim
Sent: Tuesday, August 20, 2013 8:22 PM
To: 'MarkLogic Developer Discussion'
Subject: [MarkLogic Dev General] Does adding a document to a collection trigger 
a CPF domain?

Hi Folks,

I have some documents in a directory URI with a CPF domain tied to trigger 
actions whenever a document is inserted or updated in that directory URI.  I 
would like to add the documents in this directory URI to a collection (which is 
more like adding a collection to the document). Will this trigger the CPF 
actions even though I'm not changing any content in the document?

Thank you!

Tim Meagher

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to