Someone with access to Query Console, but not to the Admin User Interface, wants to know the names of hosts in the cluster.


xdmp.hosts().toArray().map(function(host) { return xdmp.hostName(host); });
xdmp:hosts() ! xdmp:host-name(.)


The Admin UI provides a lot of information about a MarkLogic cluster: configuration of databases, application servers, groups, and other information. It also provides a means to change all these things. As such, access to it is limited to those who have the “admin” privilege. This permits a user to do anything in MarkLogic, including seeing and updating any data, so this role should be tightly held to an administration team that uses procedures to ensure mistakes don’t happen, especially in production.

Query Console, on the other hand, can be much more widely available. Developers working on a project will likely be able to use Query Console to try out queries. Their rights will likely be limited to what they need, but it doesn’t take much to run Query Console.

Sometimes team members may want to get the list of hostnames in a cluster. This recipe is a simple one-liner, but very useful all the same. xdmp:hosts() returns the IDs of all hosts in the cluster. We then feed those values to xdmp:host-name to return the human-readable names.

Learn More

Application Developer's Guide

Read the methodologies, concepts, and use cases related to application development in MarkLogic Server, with additional resources.

MarkLogic Developer Learning Track

Want to build that awesome app? Get off the ground quickly with the developer track, with instructor-led and self-paced courses.

Getting Started Video Tutorials for Developers

This series of short videos tutorials takes developers who are new to MarkLogic from download to data hub, fast.

This website uses cookies.

By continuing to use this website you are giving consent to cookies being used in accordance with the MarkLogic Privacy Statement.