Navigation

4-0 Export MarkLogic Database Content to the File System

This example uses the QueryMarkLogic processor to query a MarkLogic database, then writes the documents to the file system with the PutFile processor. We use UpdateAttribute to set the filename and path properties based on the uri property. filename is used directly by PutFile. path is used in the Directory property to construct the output directory.

The example assumes that the MarkLogic URIs are formatted like Unix paths (/my/path/file.xml). PutFile does not allow for mixed slashes in file paths. Here we replace the forward slashes in the URI with backslashes for Windows. NiFi requires that backslashes are double escaped, hence the "\\\\".

Download Template
Processors:
  • QueryMarkLogic
    • Scheduling
      • Run Schedule: 1 day
    • Properties
      • Query: <cts:true-query xmlns:cts="http://marklogic.com/cts"/>
      • Query Type: Combined Query (XML)
  • UpdateAttribute
    • Properties
      • filename: ${ filename:substringAfterLast('/') }
      • path: ${filename:substringBeforeLast('/'):replaceAll('/', "\\\\")}
  • PutFile
    • Properties
      • Directory: c:\some\directory${path}