WuKong Search全文搜索引擎
WuKong 全文搜索引擎。功能特性:
高效索引和搜索(1M條微博500M數(shù)據(jù)28秒索引完,1.65毫秒搜索響應(yīng)時(shí)間,19K搜索QPS)
支持中文分詞(使用sego分詞包并發(fā)分詞,速度27MB/秒)
支持計(jì)算關(guān)鍵詞在文本中的緊鄰距離(token proximity)
支持計(jì)算BM25相關(guān)度
可實(shí)現(xiàn)分布式索引和搜索
采用對(duì)商業(yè)應(yīng)用友好的Apache License v2發(fā)布
示例代碼:
package main
import (
"github.com/huichen/wukong/engine"
"github.com/huichen/wukong/types"
"log"
)
var (
// searcher是協(xié)程安全的
searcher = engine.Engine{}
)
func main() {
// 初始化
searcher.Init(types.EngineInitOptions{
SegmenterDictionaries: "github.com/huichen/wukong/data/dictionary.txt"})
defer searcher.Close()
// 將文檔加入索引
searcher.IndexDocument(0, types.DocumentIndexData{Content: "此次百度收購將成中國互聯(lián)網(wǎng)最大并購"})
searcher.IndexDocument(1, types.DocumentIndexData{Content: "百度宣布擬全資收購91無線業(yè)務(wù)"})
searcher.IndexDocument(2, types.DocumentIndexData{Content: "百度是中國最大的搜索引擎"})
// 等待索引刷新完畢
searcher.FlushIndex()
// 搜索輸出格式見types.SearchResponse結(jié)構(gòu)體
log.Print(searcher.Search(types.SearchRequest{Text:"百度中國"}))
}評(píng)論
圖片
表情
