Importing Documents from a Forest into a Database
- Last Updated: April 14, 2026
- 2 minute read
- MarkLogic Server
- Version 12.0
- Documentation
Use the following procedure to load all the files in a native forest directory and its sub-directories. To load selected files, see Filtering Documents Loaded from a Directory. For more details on the command line options used in this procedure, see Import Command Line Options.
-
Set
-input_file_pathto the path to the input forest directory(s). Specify multiple forests using a comma-separated list of paths.-
To select documents in one or more collections, set
-collection_filterto a comma-separated list of collection URIs. -
To select documents in one or more database directories, set
-directory_filterto a comma-separated list of directory URIs. -
To select documents by document type, set
-type_filterto a comma-separated list of document types. -
To select all documents in the database, leave
-collection_filter,-directory_filter, and-type_filterunset.
-
-
Set
-input_file_typetoforest. -
Specify the connection information for the destination database using
-host,-port,-username, and-password. -
Select the files to extract from the input forest. For details, see Filtering Forest Contents. Filtering options can be used together.
-
If you want to exclude some or all of the document metadata in the forests:
-
Set
-copy_collectionstofalseto exclude document collections metadata. -
Set
-copy_qualitytofalseto exclude document quality metadata. -
Set
-copy_metadatatofalseto exclude key-value metadata.
-
-
Set
-modetolocal(This is the default mode): Your input forests and the destination MarkLogic Server instance must be reachable from the host where you run mlcp.
By default, an imported document has a database URI based on the input file path. You can customize the URI using options. For details, see Controlling Database URIs During Ingestion.
The following example command loads the documents in the forests in /var/opt/MarkLogic/Forests/example:
# Windows users, see Modifying the Example Commands for Windows
$ mlcp.sh import -host localhost -port 8000 -username user \
-password password -input_file_type forest \
-input_file_path /var/opt/MarkLogic/Forests/example