Search code examples
restconfigurationmarklogicmarklogic-8

Set file system as modules database using MarkLogic REST API


I want to use MarkLogic 8's REST API to create an app server which uses the file system as the module database as shown in this image:

Modules database using file system

I've tried the following variations, with the results described below each command:

curl -v -X POST --anyauth -u admin:admin --header "Content-Type:application/json" \
-d '{"rest-api": { "name": "MyAppServer", "port": "8012", "database": "MyDB", "modules-database": 0 } }' \
http://127.0.0.1:8002/v1/rest-apis

Creates a database named "0" (without the quotes)

curl -v -X POST --anyauth -u admin:admin --header "Content-Type:application/json" \
-d '{"rest-api": { "name": "MyAppServer", "port": "8012", "database": "MyDB", "modules-database": "(file system) } }' \
http://127.0.0.1:8002/v1/rest-apis

Error

ADMIN-INVALIDCONFIG: (err:FOER0000) Invalid configuration: '(file system)' is not a valid database-name

If it's not possible to set the modules database using the REST API, is it possible to load files into the modules database using the REST API? I've only found documentation on inserting documents into the data database.


Solution

  • Configuring the modules database to the file system is not supported for REST API appservers.

    The REST API needs to be able to write and read documents in the modules database.

    A REST client can read and write documents in the modules database for a REST API appserver by treating it as a content database. Either:

    • Create a different REST API appserver that has the modules database as the content database. (One could think of this as a "meta" REST API appserver.)
    • Specify the database parameter when connecting to a REST API appserver.

    Just be careful not to write files in the directories managed by the REST API for a modules database:

    /GROUP_NAME/
    /marklogic.rest.*/
    /ext/
    

    Hoping that helps,