Managing JSON Documents

To perform CRUD operations (create, read, update, and delete) on JSON documents in MapR-DB JSON tables using the OJAI API, you use Document, DocumentStore, and DocumentMutation objects.

You can also perform these operations using MapR-DB Shell (JSON Tables).


To create a JSON document in Java OJAI, use the Document interface.


After you create a Document object, you can pass it to the DocumentStore interface. The interface has methods to perform the following tasks:

  • Delete documents from tables
  • Insert documents into tables
  • Replace documents in tables

See DocumentStore for details about the interface.


To make changes to JSON documents, create a DocumentMutation object. A DocumentMutation enables you to perform OJAI mutations, which includes replacing, updating, combining, and deleting fields in a JSON document. For a list of available mutations, see Using OJAI Mutation Syntax.

To create a DocumentMutation object, call the methods in the DocumentMutation class corresponding to the mutation operations you want to perform. See DocumentMutation for a list of available methods.

Pass the DocumentMutation object to either the DocumentStore.checkAndMutate or DocumentStore.update method to apply the changes to the document. The first method accepts a QueryCondition parameter that must evaluate to true for the mutation to be applied. Both methods have an _id parameter corresponding to the document to be updated.

By default, the default maximum size of a JSON document is 32 MB. A DocumentMutation does not enforce this limit. MapR-DB enforces the limit when you pass your DocumentMutation object to the DocumentStore method. See JSON Document Size for information about how to increase this limit.

See Examples: Updating JSON Documents for examples that use mutations.