Riot search

Go 开源、分布式、简单高效的搜索引擎。「Go Open Source, Distributed, Simple and efficient Search Engine」

Github stars Tracking Chart

Riot 搜索引擎

Go 开源、分布式、简单高效的全文本搜索引擎。

特性

安装/更新

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

要求

需要 Go 版本至少为 1.8

依赖

Riot 使用 go module 或 dep 管理依赖.

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"
    "github.com/go-ego/riot/types"
)
var (
    // searcher 是协程安全的
    searcher = riot.Engine{}
)
func main() {
    // 初始化
    searcher.Init(types.EngineOpts{
        Using:             3,
        GseDict: "zh",
        // GseDict: "your gopath"+"/src/github.com/go-ego/riot/data/dict/dictionary.txt",
    })
    defer searcher.Close()
    text := "《复仇者联盟3:无限战争》是全片使用IMAX摄影机拍摄"
    text1 := "在IMAX影院放映时"
    text2 := "全片以上下扩展至IMAX 1.9:1的宽高比来呈现"
    // 将文档加入索引,docId 从1开始
    searcher.Index("1", types.DocData{Content: text})
    searcher.Index("2", types.DocData{Content: text1}, false)
    searcher.Index("3", types.DocData{Content: text2}, true)
    // 等待索引刷新完毕
    searcher.Flush()
    // engine.FlushIndex()
    // 搜索输出格式见 types.SearchResp 结构体
    log.Print(searcher.Search(types.SearchReq{Text:"复仇者"}))
}

是不是很简单!

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

使用默认引擎:

package main
import (
    "log"
    "github.com/go-ego/riot"
    "github.com/go-ego/riot/types"
)
var (
    searcher = riot.New("zh")
)
func main() {
    data := types.DocData{Content: `I wonder how, I wonder why
        , I wonder where they are`}
    data1 := types.DocData{Content: "所以, 你好, 再见"}
    data2 := types.DocData{Content: "没有理由"}
    searcher.Index("1", data)
    searcher.Index("2", data1)
    searcher.IndexDoc("3", data2)
    searcher.Flush()
    req := types.SearchReq{Text: "你好"}
    search := searcher.Search(req)
    log.Println("search...", search)
}

查看更多例子

持久化的例子

逻辑搜索的例子

拼音搜索的例子

不同字典和语言例子

benchmark

Riot 搜索模板, 客户端和字典

主要改进:

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

作者

捐赠

支持 riot, buy me a coffee.

Paypal

Donate money by paypal to my account vzvway@gmail.com

其它

License

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

Overview

Name With Ownergo-ego/riot
Primary LanguageGo
Program languageGo (Language Count: 1)
PlatformLinux, Mac, Windows
License:Apache License 2.0
Release Count1
Last Release Name0.10.0 (Posted on )
First Release Name0.10.0 (Posted on )
Created At2017-06-21 14:17:59
Pushed At2020-10-13 13:31:05
Last Commit At2020-10-13 09:31:45
Stargazers Count6.1k
Watchers Count198
Fork Count476
Commits Count573
Has Issues Enabled
Issues Count88
Issue Open Count48
Pull Requests Count31
Pull Requests Open Count2
Pull Requests Close Count4
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

Riot search

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

Go Open Source, Distributed, Simple and efficient full text search engine.

简体中文

Features

Requirements

Go version >= 1.8

Dependencies

Riot uses go module or dep to manage dependencies.

Installation/Update

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

Build-tools

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

re riot

To create a new riot application

$ re riot my-riotapp

re run

To run the application we just created, you can navigate to the application folder and execute:

$ cd my-riotapp && re run

Usage:

Look at an example

package main

import (
	"log"

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

var (
	// searcher is coroutine safe
	searcher = riot.Engine{}
)

func main() {
	// Init
	searcher.Init(types.EngineOpts{
		// Using:             4,
		NotUseGse: true,
		})
	defer searcher.Close()

	text := "Google Is Experimenting With Virtual Reality Advertising"
	text1 := `Google accidentally pushed Bluetooth update for Home
	speaker early`
	text2 := `Google is testing another Search results layout with 
	rounded cards, new colors, and the 4 mysterious colored dots again`
	
	// Add the document to the index, docId starts at 1
	searcher.Index("1", types.DocData{Content: text})
	searcher.Index("2", types.DocData{Content: text1}, false)
	searcher.IndexDoc("3", types.DocData{Content: text2}, true)

	// Wait for the index to refresh
	searcher.Flush()
	// engine.FlushIndex()

	// The search output format is found in the types.SearchResp structure
	log.Print(searcher.Search(types.SearchReq{Text:"google testing"}))
}

It is very simple!

Use default engine:

package main

import (
	"log"

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

var (
	searcher = riot.New("zh")
)

func main() {
	data := types.DocData{Content: `I wonder how, I wonder why
		, I wonder where they are`}
	data1 := types.DocData{Content: "所以, 你好, 再见"}
	data2 := types.DocData{Content: "没有理由"}

	searcher.Index("1", data)
	searcher.Index("2", data1)
	searcher.Index("3", data2)
	searcher.Flush()

	req := types.SearchReq{Text: "你好"}
	search := searcher.Search(req)
	log.Println("search...", search)
}

Look at more Examples

Look at Store example

Look at Logic search example

Look at Pinyin search example

Look at different dict and language search example

Look at benchmark example

Riot search engine templates, client and dictionaries

Authors

Supporting riot, buy me a coffee.

Paypal

Donate money by paypal to my account vzvway@gmail.com

License

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

To the top