Documentation
Quick Start
Prerequisites
- Rust 1.70+ (install via rustup)
Build and Run
# Clone the repository
git clone https://github.com/overclockdb/overclockdb.git
cd overclockdb
# Build in release mode
cargo build --release
# Run the server
cargo run --release
The server starts on http://localhost:8108 by default.
Environment Variables
| Variable | Default | Description |
|---|---|---|
OVERCLOCKDB_PORT |
8108 | HTTP server port |
OVERCLOCKDB_DATA_DIR |
./data | Directory for WAL and snapshots |
OVERCLOCKDB_PERSISTENCE |
true | Enable/disable persistence |
PostgreSQL Sync Variables
| Variable | Required | Description |
|---|---|---|
POSTGRES_URL |
Yes | PostgreSQL connection string |
POSTGRES_TABLE |
Yes | Source table name |
POSTGRES_COLLECTION |
Yes | Target OverclockDB collection |
POSTGRES_PRIMARY_KEY |
No | Primary key column (default: id) |
POSTGRES_BATCH_SIZE |
No | Batch size for initial sync (default: 1000) |
Health Check
# Liveness check
GET /health
# Readiness check
GET /ready
Collections
# Create a collection
POST /api/v1/collections
Content-Type: application/json
{
"name": "products",
"fields": [
{"name": "title", "type": "string"},
{"name": "description", "type": "string"},
{"name": "price", "type": "float", "sort": true},
{"name": "category", "type": "string", "facet": true}
],
"enable_stemming": true,
"stem_language": "english",
"enable_stop_words": true,
"stop_words_language": "english"
}
# List all collections
GET /api/v1/collections
# Get collection info
GET /api/v1/collections/:name
# Delete a collection
DELETE /api/v1/collections/:name
Documents
# Create/update a document
POST /api/v1/collections/:name/docs
Content-Type: application/json
{
"id": "prod_1",
"title": "Wireless Headphones",
"description": "Premium noise-canceling headphones",
"price": 299.99,
"category": "electronics"
}
# Batch import documents
POST /api/v1/collections/:name/docs/batch
Content-Type: application/json
{
"documents": [
{"id": "1", "title": "Product 1", "price": 99.99},
{"id": "2", "title": "Product 2", "price": 149.99}
]
}
# Get a document by ID
GET /api/v1/collections/:name/docs/:id
# Replace a document
PUT /api/v1/collections/:name/docs/:id
# Delete a document
DELETE /api/v1/collections/:name/docs/:id
Search
POST /api/v1/collections/:name/search
Content-Type: application/json
{
"q": "wireless headphones",
"query_by": ["title", "description"],
"filter": "price:>=100 AND category:=electronics",
"facets": ["category"],
"sort_by": "price:asc",
"limit": 20,
"offset": 0
}
Search Parameters
| Parameter | Type | Description |
|---|---|---|
q | string | Search query |
query_by | string[] | Fields to search in |
filter | string | Filter expression |
facets | string[] | Fields to compute facet counts |
sort_by | string | Sort expression (e.g., price:asc,rating:desc) |
limit | number | Maximum results (default: 10) |
offset | number | Pagination offset (default: 0) |
typo_tolerance | number | Enable typo tolerance with max edit distance (1-2) |
vector_search | boolean | Enable hybrid semantic search (default: false) |
hybrid_alpha | number | Vector weight: 0.0 = pure BM25, 1.0 = pure vector |
language | string | ISO 639-1 language code for facet labels |
Search Response
{
"found": 150,
"took_ms": 5,
"hits": [
{
"id": "prod_1",
"score": 0.95,
"doc": {
"id": "prod_1",
"title": "Wireless Headphones",
"price": 299.99,
"category": "electronics"
}
}
],
"facets": {
"category": [
{"value": "electronics", "count": 45},
{"value": "accessories", "count": 23}
]
}
}
Field Types
| Type | Description |
|---|---|
string | Text field (indexed by default) |
string[] | Array of strings (filterable, facetable) |
int32 | 32-bit integer |
int32[] | Array of 32-bit integers (filterable) |
int64 | 64-bit integer |
int64[] | Array of 64-bit integers (filterable) |
float | 64-bit floating point |
float[] | Array of 64-bit floats (filterable) |
bool | Boolean |
hierarchy | Hierarchical category with "/" separator |
attributes | Dynamic key-value pairs for flexible faceting |
Field Options
| Option | Default | Description |
|---|---|---|
index | true | Enable full-text search |
facet | false | Enable facet counting |
sort | false | Enable sorting |
optional | false | Allow missing values |
Collection Options
| Option | Default | Description |
|---|---|---|
enable_stemming | false | Enable word stemming |
stem_language | "english" | Stemming language: "english" or "russian" |
enable_stop_words | false | Filter common words |
stop_words_language | "english" | "english", "russian", or "none" |
enable_vectors | false | Enable semantic/vector search |
vector_fields | all text | Fields to generate embeddings from |
num_shards | null | Number of shards for parallel processing |
Filtering
field:=value # Equals
field:!=value # Not equals
field:>value # Greater than
field:>=value # Greater than or equal
field:=100 AND category:^Electronics
Typo Tolerance
OverclockDB supports typo-tolerant search using the SymSpell algorithm:
POST /api/v1/collections/products/search
{
"q": "laptp",
"typo_tolerance": 2
}
With typo_tolerance: 2, the query "laptp" will match documents containing "laptop".
| Value | Description |
|---|---|
| 0 or null | Disabled (exact matching only) |
| 1 | Allow 1 character difference |
| 2 | Allow up to 2 character differences |
Stemming
Stemming reduces words to their root form for better recall:
- "running", "runs", "ran" → "run"
- "computers", "computing" → "comput"
POST /api/v1/collections
{
"name": "articles",
"fields": [{"name": "content", "type": "string"}],
"enable_stemming": true,
"stem_language": "english"
}
| Language | API Value | Notes |
|---|---|---|
| English | "english" | Porter/Snowball stemmer (default) |
| Russian | "russian" | Snowball Russian stemmer |
Stop Words
Stop words are common words like "the", "a", "is" that are filtered out:
POST /api/v1/collections
{
"name": "articles",
"fields": [{"name": "content", "type": "string"}],
"enable_stop_words": true,
"stop_words_language": "english"
}
| Language | API Value | Notes |
|---|---|---|
| English | "english" | ~120 common English words |
| Russian | "russian" | ~70 common Russian words |
| None | "none" | Disable stop words filtering |
Hierarchical Categories
The hierarchy field type enables tree-structured categories with automatic ancestor indexing.
Schema Definition
POST /api/v1/collections
{
"name": "products",
"fields": [
{"name": "title", "type": "string"},
{"name": "category", "type": "hierarchy", "facet": true},
{"name": "price", "type": "float", "sort": true}
]
}
Document Examples
// Single category
{"id": "laptop-1", "title": "MacBook Pro", "category": "Electronics/Computers/Laptops"}
// Multiple categories
{"id": "organizer-1", "title": "Desk Organizer", "category": ["Office/Supplies", "Home/Storage"]}
Searching Hierarchies
# All electronics (matches Laptops, Desktops, Phones, etc.)
{"q": "*", "filter": "category:^Electronics", "facets": ["category"]}
# Only computers
{"q": "*", "filter": "category:^Electronics/Computers"}
# Multiple hierarchies (OR)
{"q": "*", "filter": "category:^[Electronics,Clothing]"}
Drill-Down Navigation
# Get children of Electronics
{"q": "*", "facets": ["category"], "hierarchy_parent": "Electronics"}
Response includes hierarchy_facets:
{
"hierarchy_facets": {
"category": [
{"path": "Electronics/Computers", "name": "Computers", "count": 60, "depth": 1, "has_children": true},
{"path": "Electronics/Phones", "name": "Phones", "count": 40, "depth": 1, "has_children": false}
]
}
}
Internationalization (i18n)
OverclockDB supports translated facet labels for multilingual product catalogs.
Set Translations
PUT /api/v1/collections/products/translations
{
"field": "category",
"translations": [
{
"value": "Electronics",
"labels": {"en": "Electronics", "es": "Electrónicos", "de": "Elektronik"}
},
{
"value": "Electronics/Computers",
"labels": {"en": "Computers", "es": "Computadoras", "de": "Computer"}
}
]
}
Search with Language
POST /api/v1/collections/products/search
{
"q": "laptop",
"facets": ["category", "brand"],
"language": "es"
}
Response includes translated labels:
{
"facets": {
"brand": [
{"value": "apple", "label": "Apple Inc.", "count": 50}
]
},
"hierarchy_facets": {
"category": [
{"path": "Electronics", "label": "Electrónicos", "count": 100}
]
}
}
Language Fallback
When a translation is not found:
- Requested language (e.g., "es")
- English ("en")
- Raw field value
Semantic Search
Hybrid semantic search combines BM25 text matching with vector similarity.
Setup
POST /api/v1/collections
{
"name": "articles",
"fields": [
{"name": "title", "type": "string"},
{"name": "content", "type": "string"}
],
"enable_vectors": true,
"vector_fields": ["title", "content"]
}
Hybrid Search
POST /api/v1/collections/articles/search
{
"q": "machine learning applications",
"vector_search": true,
"hybrid_alpha": 0.5
}
| hybrid_alpha | Description |
|---|---|
| 0.0 | Pure BM25 (keyword matching only) |
| 0.5 | Balanced hybrid (default) |
| 1.0 | Pure vector (semantic similarity only) |
Response with Scores
{
"hits": [
{
"id": "doc_1",
"score": 0.85,
"text_score": 0.72,
"vector_score": 0.98,
"doc": { ... }
}
]
}
Context-Aware Overlays
Runtime value resolution for context-specific data like customer pricing:
POST /api/v1/collections/products/search
{
"q": "laptop",
"overlay": {
"context_key": "customer_123",
"base_field": "default_price",
"strategy": "min"
},
"sort_by": "effective_value:asc"
}
Merge Strategies
| Strategy | Description |
|---|---|
min | Use minimum of base and overlay value (default) |
override | Overlay value replaces base if present |
max | Use maximum of base and overlay value |
PostgreSQL Synchronization
Sync data from PostgreSQL for ACID transactions with OverclockDB's fast search.
Setup
export POSTGRES_URL="postgres://user:pass@localhost/mydb"
export POSTGRES_TABLE="products"
export POSTGRES_COLLECTION="products"
Sync API Endpoints
# Get sync status
GET /api/v1/sync/status
# Incremental sync (upsert-based)
POST /api/v1/sync/initial
# Atomic sync (recommended - handles deletes)
POST /api/v1/sync/atomic
# Start polling-based sync
POST /api/v1/sync/start
{"interval_secs": 60}
# Stop sync
POST /api/v1/sync/stop
Sync Modes
| Endpoint | Description | Handles Deletes |
|---|---|---|
| /sync/initial | Incremental upsert sync | No |
| /sync/atomic | Atomic swap sync (recommended) | Yes |