Skip to content

Latest commit

 

History

History
executable file
·
134 lines (99 loc) · 4.96 KB

README_zh.md

File metadata and controls

executable file
·
134 lines (99 loc) · 4.96 KB

CircleCI Status Build Status Go Report Card GoDoc Release Join the chat at https://gitter.im/go-ego/ego

QQ 群: 120563750

安装/更新

go get -u github.com/go-ego/riot

Requirements

需要 Go 版本至少 1.8

go get -u github.com/go-ego/re 

re riot

创建 riot 项目

$ re riot my-riotapp

re run

运行我们创建的 riot 项目, 你可以导航到应用程序文件夹并执行:

$ cd my-riotapp && re run

使用

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

package main

import (
	"log"

	"github.com/go-ego/riot/engine"
	"github.com/go-ego/riot/types"
)

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

func main() {
	// 初始化
	searcher.Init(types.EngineInitOptions{
		Using:             4,
		SegmenterDict: "github.com/go-ego/riot/data/dict/dictionary.txt"})
	defer searcher.Close()

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

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

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

是不是很简单!

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

主要改进:

  • 增加逻辑搜索 
  • 增加拼音搜索 
  • 增加分布式 
  • 分词等改进 
  • 增加更多 api
  • 支持 heartbeat
  • 修复 bug
  • 删除依赖 cgo 的存储引擎, 增加 badger和 leveldb 持久化引擎

Donate

支持 riot, buy me a coffee.

Paypal

Donate money by paypal to my account [email protected]

其它

License

Riot is primarily distributed under the terms of the Apache License (Version 2.0), base on wukong.