wukongd is a search engine working as a standalone service, based on wukong

yll 6f141a44a2 update: README 4 anos atrás
core 3d75a88c8c change docId to string type 4 anos atrás
data 77121830e9 第一发 12 anos atrás
docs 7fd47ae1c3 修正示例文档语法错误 9 anos atrás
engine 00b3fdde16 update: 存储引擎支持配置文件 4 anos atrás
examples 3d75a88c8c change docId to string type 4 anos atrás
storage 00b3fdde16 update: 存储引擎支持配置文件 4 anos atrás
testdata 06da509aa0 Delete weibo_data.txt 11 anos atrás
types 955b05f992 代码整理,输出整理,文档整理,统一API大小写 4 anos atrás
utils 1325da904c refactor storage 代码 10 anos atrás
wukongd 955b05f992 代码整理,输出整理,文档整理,统一API大小写 4 anos atrás
.gitignore cc7bd5c8aa add: wukongd 4 anos atrás
README.md 6f141a44a2 update: README 4 anos atrás
go.mod 00b3fdde16 update: 存储引擎支持配置文件 4 anos atrás
go.sum 00b3fdde16 update: 存储引擎支持配置文件 4 anos atrás
license.txt 77121830e9 第一发 12 anos atrás
wukong.go 3d75a88c8c change docId to string type 4 anos atrás

README.md

wukongd

wukongd 是基于 wukong 的搜索引擎。作为独立的服务进程运行

  • 增加接口函数 IndexDocumentS 文档 Id (docId) 为 string 类型。
  • 增加 REST RPC 接口。
  • 增加 wukongd.conf 配置文件 (toml 格式)。

如果需要使用 wukong 的代码, 可以直接导航到其 github repo, 或 checkout orig 分支.

wukongd REST API

  • POST http://host:port/v1/index 添加索引

参数

{
  "docId":"db:table:column:1",
  "content":"我爱这个世界", 
  "forceUpdate":false
}
  • POST http://host:port/v1/delete_index 删除索引
  • DELETE http://host:port/v1/index 删除索引

参数

{
  "docId":"db:table:column:1"
}
  • GET http://host:port/v1/search?keywords=xxx 搜索

返回 见 SearchResponse 结构体定义

wukongd 启动参数

-c 指定配置文件 -t 测试配置文件 -v 打印版本 -h

wukongd TODO

增加 API

  • shutdown
  • stat
  • if index exists already

悟空全文搜索引擎

微博搜索demo

安装/更新

go get -u -v github.com/huichen/wukong

需要Go版本至少1.1.1

使用

先看一个例子(来自examples/simplest_example.go

/*

没有比这个更简单的例子了。

*/

package main

import (
	"log"

	"github.com/huichen/wukong/engine"
	"github.com/huichen/wukong/types"
)

var (
	// searcher是线程安全的
	searcher = engine.Engine{}
)

func main() {
	// 初始化
	searcher.Init(types.EngineInitOptions{
		SegmenterDictionaries: "../data/dictionary.txt"})
	defer searcher.Close()

	// 将文档加入索引,docId 从1开始
	searcher.IndexDocumentS("db:table:1", types.DocumentIndexData{Content: "此次百度收购将成中国互联网最大并购"}, false)
	searcher.IndexDocumentS("db:table:2", types.DocumentIndexData{Content: "百度宣布拟全资收购91无线业务"}, false)
	searcher.IndexDocumentS("db:table:3", types.DocumentIndexData{Content: "百度是中国最大的搜索引擎"}, false)

	// 等待索引刷新完毕
	searcher.FlushIndex()

	// 搜索输出格式见types.SearchResponse结构体
	log.Print(searcher.Search(types.SearchRequest{Text: "百度中国"}))
}

是不是很简单!

然后看看一个入门教程,教你用不到200行Go代码实现一个微博搜索网站。

其它