How to Setup, Create a Database, and Communicate with MarkLogic

Analyzing data.
Reading Time: 5 minutes

Marklogic, Formally known as MarkLogic Server, is an enterprise NoSQL database with broad support for unstructured and unstructured data, including JSON, XML, RDF, text, and binary data types.

MarkLogic has schema flexibility, High Scalability, high availability of a NoSQL database, and enterprise features. Before starting with how to make the communication let’s understand the MarkLogic system requirement.

Christopher Lindblad founded MarkLogic in 2001, particularly in handling queries over multi-terabyte document collection.

We can install Marklogic on different operating systems:

  • Windows 7 (x64) and 8 (x64)
  • Linux
  • Mac OS
  • Microsoft Windows Server 2012 or 2008, etc.

For RAM, MarkLogic requires a minimum of 512 MB of system memory. For the disk space, MarkLogic requires 1.5 times the size of the loaded source content to allow for merging.

After installing the MarkLogic from and after setting up you can efficiently run it on your system by running the command /sbin/service MarkLogic start .

Now the MarkLogic is installed and the service has been started. The next step is we have to initialize the instance. Basically, you need to set up the user name and the password for the administrative user to set up security.

When you are done with all the above steps then you get this type of screen shown below picture where you need to enter the username and password that you already setup before entering in MarkLogic –

After the above step, your server gets started and you find out the below window:

Creating a Forest and Database

As now our instance is set up before communicating we need to create the database first. In MarkLogic database is a set of configurations or we can say that it is a collection of forests.

Now the question arises of what exactly the forest means here. So basically the forest is something where the documents in a database are physically stored.

Now let’s see how to create a forest in Marklogic. You need to click on the forest section first and then go to the create section that is shown in the below window.

Here you just need to fill in the forest name the only mandatory thing.

Now, if you want to check whether your new forest is created or not you just need to run ls /var/opt/MarkLogic/Forests in the command prompt.

Now we need to create a database by choosing database and then choosing the create option which is shown :

After clicking on ok, get a notification where it informs you that your database is not attached to the forest.

We need to attach the database to the forest now. Just click on the Database -> Forests which is shown in the above picture. After clicking on it you are going to get a new window for the attachment. Then select the option attached and click ok.

After this, you can check the status of whether your database is attached to the forest or not. You need to click on the database name that you created which is present on the left side of the server.

At last, our database is created successfully.

Communicating with MarkLogic

Now we need to communicate with MarkLogic so we have different administrative as well as development interfaces to communicate.

Let’s elaborate on some of the administrative interfaces and development interfaces:

  • Admin Interface: It is implemented as a MarkLogic Server web application. By default, it runs on port 8001 of your hosts. Also, it provides a GUI for a multitude of administrative tasks such as creating and configuring databases, forests, security, etc.
  • Admin API: Modifies MarkLogic Server configuration files that are stored on the file system, not in a database.
  • Configuration Manager: It allows you to view the configuration settings for MarkLogic Server resources. 
  • Monitoring Dashboard: It provides task-based views of MarkLogic Server performance metrics in real-time.
  • Query Console: It is an interface that allows the developers to communicate with MarkLogic by writing and testing the queries.
  • XQuery (XML Query): A query and functional programming language that queries and transforms collections of structured and unstructured data. It’s a native programming language in MarkLogic.
  • JavaScript is included in the common development interface. It is also a native programming language in MarkLogic.
  • REST API a common development interface provides a programming language for developers to use to communicate with the MarkLogic.

Using the Query Console

Query console interface readily available on port 8000(http://localhost:8000/qconsole/) and allow us to execute the XQuery and JS expressions easily.

Now if you want to execute a query then you need to select the database from the dropdown. If you want to explore or edit the database then you can do it by just clicking on explore. You can also select the app server and set the query language from the dropdown. On the right side, the active workspace is also present.

Now after selecting everything our query editor is ready to work. After writing the query you can run it by clicking on the run button successfully and you get the result. There is a feature present in the run environment that you can change the format for query result display.

You can use one more feature which is the editor option. The editor options enable you to configure the auto-close functions for parenthesis using auto-complete. You can also control indenting, matching brackets, and closing brackets.

Now setting up everything you can write queries in different languages by selecting the query type in which you are comfortable.


In this blog, we learn how we can set up the database, and for the database, the forest plays an important role. Also, Marklogic provides different query types so developers can choose their suitable type. MarkLogic is most uniquely useful for querying over massive document stores.


Written by 

Pratibha Yadav is a Software consultant at Knoldus and started her beautiful journey of a career in an environment where she able to sharp - up her skills day by day by learning and earning new opportunities. She completed her Post-graduation from Sharda University, Greater Noida. She is passionate about her work and has knowledge of various programming languages. She is recognized as a quick learner, problem solver, public speaker, dedicated and responsible professional employee. Her hobbies are Writing, Reading, and spending some time with nature.