aegis-document
Document store engine for the Aegis Database Platform.
Overview
aegis-document provides a flexible document storage system with schema-optional JSON storage, full-text search, JSONPath queries, and schema validation. It's designed for semi-structured data that doesn't fit traditional relational models.
Features
- Schema-Optional - Store any JSON document
- Collections - Logical grouping of documents
- Full-Text Search - Tokenized text search with ranking
- JSONPath Queries - Query nested document fields
- Schema Validation - Optional JSON Schema enforcement
- Secondary Indexes - Index any field for fast lookups
Architecture
┌─────────────────────────────────────────────────┐
│ Document Engine │
├─────────────────────────────────────────────────┤
│ Query Processor │
│ ┌──────────┬──────────────┬─────────────────┐ │
│ │ JSONPath │ Full-Text │ Aggregation │ │
│ │ Parser │ Search │ Engine │ │
│ └──────────┴──────────────┴─────────────────┘ │
├─────────────────────────────────────────────────┤
│ Index Manager │
│ ┌──────────┬──────────────┬─────────────────┐ │
│ │ B-Tree │ Inverted │ Composite │ │
│ │ Index │ Index │ Index │ │
│ └──────────┴──────────────┴─────────────────┘ │
├─────────────────────────────────────────────────┤
│ Collection Manager │
│ (Schema Validation Layer) │
└─────────────────────────────────────────────────┘
Modules
| Module | Description |
|---|---|
engine |
Main document engine |
collection |
Collection management |
query |
Document query execution |
index |
Secondary index management |
validation |
JSON Schema validation |
types |
Document type definitions |
Usage
[]
= { = "../aegis-document" }
Collections
use ;
let engine = new?;
// Create a collection
engine.create_collection?;
// Create with schema validation
let schema = json!;
engine.create_collection?;
CRUD Operations
// Insert
let doc_id = engine.insert?;
// Find by ID
let doc = engine.find_by_id?;
// Update
engine.update?;
// Delete
engine.delete?;
Querying
use ;
// Simple filter
let results = engine.find?;
// Complex query
let results = engine.find?;
// Nested field query (JSONPath)
let results = engine.find?;
Full-Text Search
use ;
// Create text index
engine.create_index?;
// Search
let results = engine.search?;
for result in results
Aggregation
use ;
let results = engine.aggregate?;
Update Operators
| Operator | Description | Example |
|---|---|---|
$set |
Set field value | {"$set": {"name": "Bob"}} |
$unset |
Remove field | {"$unset": {"temp": ""}} |
$inc |
Increment number | {"$inc": {"count": 1}} |
$push |
Add to array | {"$push": {"tags": "new"}} |
$pull |
Remove from array | {"$pull": {"tags": "old"}} |
$addToSet |
Add unique to array | {"$addToSet": {"tags": "x"}} |
Configuration
[]
= { = 1000000 }
= "english"
[]
= true
= true
Tests
Test count: 634 tests (workspace total)
License
Apache-2.0