Search code examples
database-migrationmarklogicdatabase-restoremarklogic-7marklogic-10

Managed document not working in MarkLogic 10 after xdmp:document-insert


  1. First time manage document using dls:document-insert-and-manage
  2. Update the same document using xdmp:document-insert
  3. Document get lost from the dls latest version collection cts:search(/scopedIntervention/id , dls:documents-query())

  4. First time manage document

    <scopedIntervention>
      <id>someId12345</id>
      <scopedInterventionName>
        First Name
      </scopedInterventionName>
      <forTestOnly>
        true
      </forTestOnly>
      <inactive>
        true
      </inactive>
    </scopedIntervention>)```
    **Document inserted with versioning**
    
  5. Verify document is present in latest documents collection

    cts:search(/scopedIntervention/id , dls:documents-query())

    Document present in managed latest collection

  6. Update the same document

    <scopedIntervention>
      <id>someId12345</id>
      <scopedInterventionName>
        Updated Name
      </scopedInterventionName>
      <forTestOnly>
        true
      </forTestOnly>
      <inactive>
        true
      </inactive>
    </scopedIntervention>)```
    
    **Update document to same URI using xdmp:document-insert**
    
  7. Again verify document is present or NOT in latest documents collection

    cts:search(/scopedIntervention/id , dls:documents-query())

    Document NOT present in managed latest collection (lost from collection)

After applying DLS package using following upgrade step, the same document shows in the list ```xquery version "1.0-ml"; import module namespace dls = "http://marklogic.com/xdmp/dls" at "/MarkLogic/dls.xqy";

dls:set-upgrade-status(fn:false()),
dls:start-upgrade(),
fn:doc("http://marklogic.com/dls/upgrade-task-status.xml"),
dls:latest-validation-results(),
dls:set-upgrade-status(fn:true())```

Solution

    1. Update the same document using xdmp:document-insert

    You are most likely removing the DLS Latest collection at this step. Further, version history is not preserved when you do this.

    Instead of using xdmp:document-insert you should use dls:document-checkout-update-checkin .