MarkLogic Data Hub Service

Fast data integration + improved data governance and security, with no infrastructure to buy or manage.

Learn More


Stay On Top Of Everything MarkLogic

Be the first to know! News, product information, and events delivered straight to your inbox.

Sign Me Up


MarkLogic World 2019

Learn how to simplify data integration & build innovative applications. Join us in Washington D.C. May 14-15!

Find Out More


Stay On Top Of Everything MarkLogic

Be the first to know! News, product information, and events delivered straight to your inbox.

Sign Me Up

Welcome to the MarkLogic Server playground!

This tutorial gets you started writing queries against MarkLogic Server. We'll begin with some simple one-liner queries, progress to some modular programs, and along the way explore how to use XPath, XQuery, and MarkLogic's Search API.

We assume you know the basics. If you're truly brand new, you should probably jump out and find some introductory material, then come back.

All the sample code you'll see is live and you're invited to execute it as we go along. You can (and should) tweak it with your own changes. For a test data set, we've loaded roughly 5,000,000 emails that were copied over from the site. Each email is represented by an XML document, and for mails that have attachments they're held in separate binary documents within the database with links in the main XML document.

We've placed the data on a single shared RackSpace virtualized machine. We're using security rules so you (as a public user) can read, but not write, to the database, and each query is allowed a maximum of 10 seconds to complete before it's forcibly killed.

You may want to refer to the API documentation as you follow along.

Lay of the Land

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.


The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.
  • Great tutorial. tnx
  • I have gone through a lot of programs of such types but after having 50 emails XML I just came to know that there is still a lot to know and that moment I realized that Internet is a sea and you learn new thing every time.
  • Hello, this is fastidious post I actually loved reading this. <a href="">buy like</a>
  • Info is implausible, I would want to see more and more from your writers. <a href="">sewa mobil</a>
  • I assume the admin of this website is truly working onerous in favor of his internet site, since here each data is quality based mostly. <a href="">wedding stationary</a>
  • Your blogs are easily accessible and quite enlightening so keep doing the amazing work guys. <a href="">wikipedia reference</a>
  • Living it up; living advertisement statesman n a lot more.<a href="">bubblegum casting reviews</a>
  • Great tutorial.
  • I am new to MarkLogic, but I know a bit of Xquery and this could potentially add to my DB portfolio.
  • All elements and attributes are indexed.  Some are indexed in specific ways beyond the defaults. 
    •  Does this mean that the "separate binary documents" mentioned of the attachments are also indexed?  Wouldn't this take up a lot of disk space?
      • They are stored.  We could extract and index their metadata, but have not done so for this sample.   MarkLogic can store binaries "internally in the database" and/or "externally outside of the database".  In this example, we are storing them in the database.  See for more details on binaries.
  • I would like to know what elements and/or attributes of the email xml  are indexed.