How manticoresoftware/manticoresearch works
Project Type and Purpose
• Manticore Search is an open-source, high-performance search database engine written in C++. It provides:
• SQL interface (MySQL wire protocol)
• HTTP/JSON REST interface
• Batch indexing (indexer tool) and real-time indexing
• Multi-master replication (Galera)
• Row-wise, columnar and docstore storage engines
• Plugin/UDF extensibility
High-Level Architectural Components
A. Clients & External Interfaces
• MySQL-compatible clients (e.g., mysql CLI, connectors)
• HTTP/JSON clients (curl, REST tools)
• Language-specific SDKs (Python, Ruby, Go, etc.)
B. Search Daemon (searchd)
• Network Front-Ends
• MySQL protocol handler
• HTTP/JSON handler
• Parser & Planner
• SQL parser (bison/flex)
• JSON schema manager
• Cost-based query optimizer
• Query Execution Engine
• Query operators (filter, aggregator, join, KNN)
• Inverted-index & PGM-index access
• Columnar/row-wise storage layer
• Real-Time Index Engine
• In-memory RT segment management
• Binary log writer/reader
• Replication Module
• Galera client library interface
• Cluster state manager, binlog applier
• Storage Subsystems
• On-disk index files, columnar library
• Docstore for raw payload retrieval
• Auxiliary Services
• Configuration reloader
• Crash log and query log subsystem
• Monitoring / metrics (telemetry)
C. Batch Indexing Tool
• indexer CLI
• Connector submodules (source_mysql, source_xml, source_csv, ODBC, Kafka)
• Schema configurator
• Output: on-disk index files
D. Build & Packaging
• CMake build system with modular cmake/Find*.cmake
• Docker build pipelines (dist/build_dockers)
• Packaging scripts (deb, rpm, nsis)
E. Documentation and Test Suite
• manual/ (user docs)
• test/ (CLT tests, unit tests, benchmarks)
Relationships and Data Flows
• Client → (MySQL/TCP or HTTP/JSON) → searchd Front-End
• Front-End → Parser → Query Planner → Execution Engine
• Execution → Storage Access → Disk/Memory
• Real-Time Inserts → RT Engine → Memory segments & Binlog
• Batch Indexing (indexer) → Reads source → Builds index files → searchd picks up on rotate
• Replication → Galera over network → Applies changes to local RT segments & binlogs
• Configuration changes → Config Reloader → Restarts sub-components
Architectural Patterns & Principles
• Modular C++ components split by function (networking, parsing, storage, replication)
• Layered architecture: protocol → parser → planner → executor → storage
• Plugin extensibility: UDFs, tokenizers, searchd plugins
• Multi-threaded design: request dispatch, worker threads for query & indexing
• Separate batch and real-time indexing pipelines
Essential Details to Capture
• Dual front-end (MySQL vs HTTP) converging into the same query engine
• Distinct paths for batch vs real-time indexing
• Replication logic separate from query execution but writing/applying binlogs
• Storage engine pluggability (columnar library as external submodule)
• Build and packaging layers as supporting infrastructure