CRUD

Yep that's Create, Read, Update, and Delete. We use the term Insert instead of Create but that doesn't keep us from saying CRUD for fun. MarkLogic provides a simple Java API for CRUD.

The first step is to use our DatabaseClient instance (client) to get a DocumentManager instance (in this case, a JSONDocumentManager instance):

To insert a document, call the write() method:

In the above case, the JSON document is provided using a StringHandle, which is one of many different handle types you can use as wrappers for content passed to and from MarkLogic.

To get the document back, call the read() method:

If I prefered to have MarkLogic automatically generate a unique URI, I could instead do

(This call will return a DocumentDescriptor that can be queried for the new URI.)

Updating (replacing) the document works exactly the same as creating a document: use the write() method.

To delete the document, call the delete() method:

The Java API provides additional functionality related to CRUD, including

These techniques are covered in the Java Application Developer's Guide.

Basic Concepts

Search APIs

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