Coder Social home page Coder Social logo

riot's Introduction

Appveyor codecov Go Report Card GoDoc GitHub release Join the chat at https://gitter.im/yanjingang/ego

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

Features

安装/更新

#0.配置GOPROXY
 vim ~/.bashrc
  #go
  export GO111MODULE=on
  export GOPROXY=https://goproxy.io

source ~/.bashrc

#1.直接安装
go get -u github.com/yanjingang/riot

#或 本地编译
git clone https://github.com/yanjingang/riot.git
cd riot
go build
*注:本地编译修改依赖库url时,需要把go.mod里的对应version改为master后重新go build


#测试
go run examples/simple/zh/main.go 

Requirements

需要 Go 版本至少 1.8

Dependencies

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

使用

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

package main

import (
	"log"

	"github.com/yanjingang/riot"
	"github.com/yanjingang/riot/types"
)

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

func main() {
	// 初始化
	searcher.Init(types.EngineOpts{
		Using:             3,
		GseDict: "zh",
		// GseDict: "your gopath"+"/src/github.com/yanjingang/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/yanjingang/riot"
	"github.com/yanjingang/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)
}
go get -u github.com/yanjingang/re 

re riot

创建 riot 项目

$ re riot my-riotapp

re run

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

$ cd my-riotapp && re run

主要改进:

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

Authors

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.

riot's People

Contributors

vcaesar avatar yanjingang avatar szyhf avatar h8liu avatar appleboy avatar dmitryolshansky avatar mirzazulfan avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.