MarkLogic XML and JSON Storage, Indexing, and Querying

This article explores how MarkLogic handles enterprise-grade data management for structured and semi-structured XML and JSON documents. It details the underlying storage architecture, the mechanics of MarkLogic’s Universal Indexing, its multi-model query execution engine, and the distributed clustering model that enables high-throughput scalability with full ACID compliance.

Storage Architecture: Forests, Stands, and Immutable Data

MarkLogic treats JSON documents and XML fragments as first-class primitives. Unlike traditional relational databases that require rigid schemas, MarkLogic persists documents as structured hierarchical trees directly onto disk in an optimized binary format.

The Universal Index: Ingestion Without Predefined Schemas

MarkLogic eliminates the need to manually design and maintain indexes for standard operations through its built-in Universal Index.

Because index entries are created during the write pipeline, read operations bypass the need for full document scans.

Query Processing: Search Meets Database Queries

MarkLogic merges full-text search engine technology with structured query capabilities, executing operations through a two-phase query evaluation process.

  1. Index Resolution (Filtered Phase): The query engine evaluates the query criteria strictly against the in-memory indexes. This step returns a candidate list of matching document fragments (Fragment IDs) with extreme speed, eliminating irrelevant data.
  2. Document Filtering (Unfiltered Phase): If a query requires deep verification not fully covered by the indexes (e.g., complex wildcards or custom stemmers), the engine inspects the actual persisted document data from the candidate list to guarantee 100% accuracy.

Query Interfaces

Enterprise developers can query MarkLogic using several native paradigms: * Optic API: A unified data access interface enabling relational-style operations (joins, group-bys, aggregates) across documents, triples, and rows. * Server-Side JavaScript and XQuery: Native runtime environments running inside the database layer, minimizing network latency for data-intensive transformations. * SQL and SPARQL: Standard SQL support via ODBC/JDBC drivers for business intelligence tools, and SPARQL for querying semantic RDF graph data. * REST APIs: Standard HTTP interfaces for cross-platform integration and search-style document retrieval.

Scalability and Distributed Clustering

MarkLogic achieves horizontal scalability through a shared-nothing, distributed architecture that scales compute and storage independently.