riot 分布式全文搜索引擎, 采用 Go 语言开发。功能特性:
- 高效索引和搜索( 1M 条微博 500M 数据 28 秒索引完,1.65 毫秒搜索响应时间,19K 搜索 QPS )
- 支持中文分词(使用 gse 分词包并发分词,速度 27MB/秒)
- 支持逻辑搜索
- 支持中文转拼音搜索
- 支持计算关键词在文本中的紧邻距离( token proximity )
- 支持计算 BM25 相关度
- 支持自定义评分字段和评分规则
- 支持在线添加、删除索引
- 支持多种持久存储
- 支持 heartbeat
- 支持分布式索引和搜索
- 可实现分布式索引和搜索
- 采用对商业应用友好的 Apache License v2 发布
示例代码:
package main
import (
"log"
"github.com/go-ego/riot/engine"
"github.com/go-ego/riot/types"
)
var (
// searcher is coroutine safe
searcher = engine.Engine{}
)
func main() {
// Init searcher
searcher.Init(types.EngineInitOptions{
Using: 5,
SegmenterDict: "./dict/dictionary.txt"})
defer searcher.Close()
// Add the document to the index, docId starts at 1
searcher.IndexDocument(1, types.DocIndexData{Content: "Google Is Experimenting With Virtual Reality Advertising"}, false)
searcher.IndexDocument(2, types.DocIndexData{Content: "Google accidentally pushed Bluetooth update for Home speaker early"}, false)
searcher.IndexDocument(3, types.DocIndexData{Content: "Google is testing another Search results layout with rounded cards, new colors, and the 4 mysterious colored dots again"}, false)
// Wait for the index to refresh
searcher.FlushIndex()
// The search output format is found in the types.SearchResponse structure
log.Print(searcher.Search(types.SearchRequest{Text: "google testing"}))
}
主要改进:
- 增加逻辑搜索
- 增加拼音搜索
- 增加分布式和 heartbeat
- 分词等改进
- 增加更多 api
- 修复 bug
- 删除依赖 cgo 的存储引擎, 增加 badger 和 leveldb 持久化引擎
项目详情:
Github 在线源码: https://github.com/go-ego/riot