In this situation I would probably use xdmp:node-delete. That way you can 
select which of the two documents to keep, and which to delete. For example the 
first one might be the preferred version, so we want to delete the second one.

    xdmp:node-delete(doc($uri)[2])

Be sure to delete the document-node, not the root element.

-- Mike

On 26 Jun 2013, at 04:38 , Geert Josten <[email protected]> wrote:

> Apart from this, I don't see why delete doc and remove from collection
> wouldn't work..
> 
> G.
> 
>> -----Oorspronkelijk bericht-----
>> Van: Geert Josten [mailto:[email protected]]
>> Verzonden: woensdag 26 juni 2013 13:37
>> Aan: MarkLogic Developer Discussion
>> Onderwerp: RE: [MarkLogic Dev General] Two document nodes at the same
>> URI
>> 
>> A similar case has been mentioned before on the list, perhaps search
> with
>> markmail to get hold of the conclusions back then. It had been
> mentioned,
>> I thought, that you can indeed create such a situation if you ingest a
>> document in forest a, disconnect that, ingest it in forest b, than
> connect
>> a as well. I would expect MarkLogic to complain if you insert it twice
>> explicitly pointing to two different forest, but haven't tried..
>> 
>> Kind regards,
>> Geert
>> 
>>> -----Oorspronkelijk bericht-----
>>> Van: [email protected] [mailto:general-
>>> [email protected]] Namens Whitby, Rob
>>> Verzonden: woensdag 26 juni 2013 13:28
>>> Aan: MarkLogic Developer Discussion
>>> Onderwerp: Re: [MarkLogic Dev General] Two document nodes at the
>> same
>>> URI
>>> 
>>> Or if a forest is detached while documents are inserted
>>> 
>>> 
>>> On 26 Jun 2013, at 12:24, David Lee <[email protected]> wrote:
>>> 
>>>> This can also happen if you have put data into 2 forests explicitly
>> and not
>>> been very careful of guarenteeing URI uniqueness.
>>>> 
>>>> 
>>>> 
>> 
> --------------------------------------------------------------------------
>> ---
>>>> David Lee
>>>> Lead Engineer
>>>> MarkLogic Corporation
>>>> [email protected]
>>>> Phone: +1 812-482-5224
>>>> Cell:  +1 812-630-7622
>>>> www.marklogic.com
>>>> 
>>>> 
>>>> From: [email protected] [mailto:general-
>>> [email protected]] On Behalf Of Ellis Pritchard
>>>> Sent: Wednesday, June 26, 2013 6:53 AM
>>>> To: Florent Georges; MarkLogic Developer Discussion
>>>> Subject: Re: [MarkLogic Dev General] Two document nodes at the same
>>> URI
>>>> 
>>>> Hi Florent,
>>>> 
>>>> Could you have duplicate URIs in your database?
>>>> 
>>>> I believe this situation could be created by turning locking off,
>> perhaps
>>> during a bulk load containing duplicate document URIs:
>>>> 
>>>> .         locking specifies how robust transaction locking should
> be.
>> When
>>> set to strict, locking enforces mutual exclusion on existing documents
>> and
>>> on new documents. When set to fast, locking enforces mutual exclusion
>> on
>>> existing and new documents. Instead of locking all the forests on new
>>> documents, it uses a hash function to select one forest to lock. In
>> general,
>>> this is faster than strict. However, for a short period of time after
> a
>> new
>>> forest is added, some of the transactions need to be retried
> internally.
>>> When set to off, locking does not enforce mutual exclusion on existing
>>> documents or on new documents; only use this setting if you are sure
> all
>>> documents you are loading are new (a new bulk load, for example),
>>> otherwise you might create duplicate URIs in the database.
>>>> 
>>>> (from database Admin Help panel)
>>>> 
>>>> Ellis.
>>>> 
>>>> 
>>>> On 26 Jun 2013, at 11:43, Florent Georges <[email protected]>
> wrote:
>>>> 
>>>> 
>>>>  Hi,
>>>> 
>>>>  In a production environment on another project, at the client's I
> am
>>>> currently working for, they found a very weird situation.  It turns
>>>> out that one document URI contains 2 document nodes.  This has been
>>>> verified by the following queries:
>>>> 
>>>>    count(doc('...'))
>>>>       ==> 2
>>>> 
>>>>    doc('...') instance of document-node()
>>>>       ==> false
>>>> 
>>>>    doc('...') instance of document-node()+
>>>>       ==> true
>>>> 
>>>>  Is anyone aware of that bug?  Is there anything we should pay
>>>> attention to?  Is it possible to xdmp:document-delete it (them)?  Is
>>>> it possible to remove it (them) from a collection they are part of?
>>>> 
>>>>  MarkLogic version: 6.0-2.3.
>>>> 
>>>>  Regards,
>>>> 
>>>> 
>>>> --
>>>> Florent Georges
>>>> http://fgeorges.org/
>>>> http://h2oconsulting.be/
>>>> _______________________________________________
>>>> General mailing list
>>>> [email protected]
>>>> http://developer.marklogic.com/mailman/listinfo/general
>>>> 
>>>> _______________________________________________
>>>> General mailing list
>>>> [email protected]
>>>> http://developer.marklogic.com/mailman/listinfo/general
>>> 
>>> 
>>> _______________________________________________
>>> General mailing list
>>> [email protected]
>>> http://developer.marklogic.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
> 

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

Reply via email to