TigerDB 是一个兼容 Elasticsearch API 的全文搜索引擎,基于 Bleve 构建。支持多协议访问,提供高性能的全文搜索和数据分析能力。
- 🔍 Elasticsearch API 兼容:支持大部分 ES 7.x Query DSL
- 🚀 高性能:基于 Bleve,纯 Go 实现,无外部依赖
- 🔌 多协议支持:ES、Redis、MySQL、PostgreSQL(部分预留)
- 📊 查询优化:保守的查询优化器,确保不产生负优化
- 📝 完善的日志系统:多级别、多输出、自动轮转
- ⚙️ 灵活配置:配置文件、环境变量、命令行参数
- 🛡️ 生产就绪:完善的错误处理、监控指标、健康检查
# 克隆代码
git clone https://github.com/lscgzwd/tigerdb.git
cd tigerdb
# 构建
go build -o tigerdb ./cmd/tigerdb
# 运行
./tigerdb# 创建索引
curl -X PUT "localhost:19200/my_index" -H 'Content-Type: application/json' -d'
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"title": { "type": "text" },
"age": { "type": "integer" }
}
}
}'
# 索引文档
curl -X POST "localhost:19200/my_index/_doc/1" -H 'Content-Type: application/json' -d'
{
"title": "Hello TigerDB",
"age": 25
}'
# 搜索文档
curl -X GET "localhost:19200/my_index/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"match": {
"title": "TigerDB"
}
}
}'- 配置示例 - 完整的配置示例
创建 config.yaml:
# 数据目录
data_dir: "./data"
# Elasticsearch 协议
es:
enabled: true
host: "0.0.0.0"
port: 19200
# 日志配置
logging:
level: "info"
output: "stdout"
format: "text"export TIGERDB_DATA_DIR=./data
export LOG_LEVEL=debug
export LOG_OUTPUT=./logs/tigerdb.log./tigerdb --config config.yaml --data-dir ./data --es-port 19200配置优先级:命令行 > 环境变量 > 配置文件 > 默认值
| 操作 | 性能 |
|---|---|
| 简单查询 | < 10ms |
| 复合查询 | < 50ms |
| 批量索引 | > 1000 docs/s |
| 内存占用 | < 500MB(小索引) |
match,match_all,match_phrasemulti_match,query_string
term,terms,exists,idsprefix,wildcard,regexp,fuzzy
bool(must/should/must_not/filter)dis_max,boosting
range(支持数字、日期、字符串)
geo_bounding_box,geo_distance
nested(嵌套文档查询)
go build ./cmd/tigerdbgo test ./...LOG_LEVEL=debug ./tigerdb- Go 1.20+
- github.com/blevesearch/bleve_index_api
- github.com/gorilla/mux
- gopkg.in/natefinch/lumberjack.v2
欢迎贡献代码!请参阅 CONTRIBUTING.md
Apache License 2.0 - 详见 LICENSE
- Bleve - 底层搜索引擎
- Elasticsearch - API 兼容目标
- Issue: https://github.com/lscgzwd/tigerdb/issues
- Email: lscgzwd@gmail.com
TigerDB - 高性能、易部署的全文搜索引擎