Discover Packages
github.com/huichen/wukong
package
module
Version:
v0.0.0-...-ecbd39f
Opens a new window with list of versions in this module.
Published: Aug 24, 2021
License: Apache-2.0
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 0 modules, 0 packages
The first number is the count of modules that contain a package that imports this one.
The module count is a better indicator of popularity than the package count.
A module with 100 importing packages is counted only once instead of 100 times,
reflecting the fact that the choice to use the package was likely made only once,
not 100 times.
A '?' means that the value hasn't been computed yet.
Opens a new window with list of known importers.
README
README
¶
悟空全文搜索引擎
微博搜索demo
安装/更新
go get -u -v github.com/huichen/wukong
需要Go版本至少1.1.1
使用
先看一个例子(来自examples/simplest_example.go )
package main
import (
"github.com/huichen/wukong/engine"
"github.com/huichen/wukong/types"
"log"
)
var (
// searcher是协程安全的
searcher = engine.Engine{}
)
func main() {
// 初始化
searcher.Init(types.EngineInitOptions{
SegmenterDictionaries: "github.com/huichen/wukong/data/dictionary.txt"})
defer searcher.Close()
// 将文档加入索引,docId 从1开始
searcher.IndexDocument(1, types.DocumentIndexData{Content: "此次百度收购将成中国互联网最大并购"}, false)
searcher.IndexDocument(2, types.DocumentIndexData{Content: "百度宣布拟全资收购91无线业务"}, false)
searcher.IndexDocument(3, types.DocumentIndexData{Content: "百度是中国最大的搜索引擎"}, false)
// 等待索引刷新完毕
searcher.FlushIndex()
// 搜索输出格式见types.SearchResponse结构体
log.Print(searcher.Search(types.SearchRequest{Text:"百度中国"}))
}
是不是很简单!
然后看看一个入门教程 ,教你用不到200行Go代码实现一个微博搜索网站。
其它
Expand ▾
Collapse ▴
Documentation
¶
There is no documentation for this package.
Source Files
¶
Directories
¶
examples
悟空性能测试
一个微博搜索的例子。
Click to show internal directories.
Click to hide internal directories.