Learning the MarkLogic REST API
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