朱诺号木星探测器是目前人类是制造出最快的宇宙飞行器。 这里,朱诺是一个通用的易用的高性能的内存型广告检索引擎
- 通用性: 能试用广告检索的大部分情况
- 易用性: 可以极低的代价从0搭建搜索引擎
- 高性能: 本身搜索性能20ms内,单机QPS>1-2K
- 插件化,可扩展: 检索各模块都是接口的形式,可以根据需求轻松定制
- 支持倒排索引
- 数值型(int64)
- 字符串型 (string)
- 切片 ([]int64 []string)
- 正排索引
- 数值型(int, double)
- 字符串型
- set集合
- List
- KV
- 查询支持多索引查询、布尔查询、范围查询、集合查询
见example.go
搜索引擎主要分为2个部分
- 索引
- 查询
type Index interface {
Add(docInfo *document.DocInfo) error // 新增文档
Del(docInfo *document.DocInfo) error // 删除文档
GetDataType(fieldName string) document.FieldType // 获取field类型
Dump(filename string) error // 将索引Dump到磁盘 TODO
Load(filename string) error // 从磁盘加载索引 TODO
DebugInfo() *debug.Debug // 调试信息
}type DocInfo struct {
Id DocId // id
Fields []*Field // 属性信息
}
type Field struct {
Name string // 名称
IndexType IndexType // 索引类型 1:倒排 2:正排 3:both
Value interface{} // value值
ValueType FieldType // value类型
}json结构
{
"Id": 12345,
"Fields": [
{
"FieldName": "Field1",
"value":"value",
"indexType":0
},
{
"FieldName": "Field2",
"value":"value",
"indexType":1
},
{
"FieldName": "Field3",
"value":"value",
"indexType":2
}
]
}查询是类sql语法,有表达式组成(可嵌套),表达式有 and, or, not等操作
支持 =, >=, >, <=,<, !=, range(暂不支持), in, !in
查询语法支持三种格式 string, json, go struct
{
"and": [
{
"=": {
"field": "country",
"value": "US"
}
},
{
"range": {
"field": "price",
"value": [
1,
20
]
}
},
{
"or": [
{
"=": {
"field": "platform",
"value": "ios"
}
},
{
"in": {
"field": "packageName",
"value": [
"package1",
"package2"
]
}
}
]
}
]
}type Query interface {
Next() (document.DocId, error)
Current() (document.DocId, error)
GetGE(id document.DocId) (document.DocId, error)
DebugInfo() *debug.Debug
}