Learning the MarkLogic REST API

Evan Lenz
Last updated 2012-09-14

MarkLogic is an enterprise-class NoSQL database built on search engine technology. This tutorial will walk you through a series of HOWTOs for working with MarkLogic exclusively through its REST API.


If you'd prefer to work with MarkLogic using Java, start instead with MarkLogic for Java developers.

 

MarkLogic's REST API allows you to create, read, update, and delete documents (CRUD), as well as search documents and perform analytics on the values they contain. The REST API gives you the building blocks you need for a faceted search application's data layer, using your language of choice (e.g., Ruby, Python, PHP, etc.). For purposes of this tutorial, you'll be using the cURL command-line utility to interactively learn the REST API.

MarkLogic basics

The basic unit of organization in MarkLogic is the document. Documents can occur in one of four formats:

  • XML
  • JSON
  • text
  • binary

Each document is identified by a URI, such as "/example/foo.json", which is unique within the database.

As with files on a filesystem, documents can be grouped into directories. This is done implicitly via the URI. For example, the document with the URI "/docs/plays/hamlet.xml" resides in the "/docs/plays/" directory.

Documents can also be grouped (independently of their URI) into collections. A collection is essentially a tag (string) associated with the document. A document can have any number of collection tags associated with it. Collections represent one kind of metadata that can be associated with documents. We'll see how to manipulate both document content and metadata.

Setup

Comments

  • I am looking for some python code to use the ML REST API anyone? hugo
    • Hey there, I know a python user who's done some work here. I'll check in with him.
  • Is it there in version 5 also.
    • The REST API is new in MarkLogic 6.  If you need a REST API for MarkLogic before version 6, please see http://github.com/marklogic/Corona - there is a brief tutorial at http://developer.marklogic.com/try/corona/index ; the Corona wiki is also helpful : https://github.com/marklogic/Corona/wiki