Go Open Source, Distributed, Simple and efficient Search Engine

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

License

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

Comments
  • Propose Logo

    Propose Logo

    Hi,, i'm graphic designer and an open source enthusiast. I would like to contribute to your awesome project by proposing logo design for it if you allow me. I'll be doing it as a gift for free to your awesome project. Best regard. Mirza zulfan.

  • [Question or PR] Can tow engine share the same segmenter at the same time?

    [Question or PR] Can tow engine share the same segmenter at the same time?

    Description

    For some reason I have to use more than one engine at the same process, but while init each engine have to load the dictionary for segment, that cost a lot of time and memory, if I share the segmenter for different engine, will that case the concurrent problem?

    If it can be done, may I make a PR for this engine option? ...

  • A Newbie Question About Many CN Keywords Not Searchable in Example codelab

    A Newbie Question About Many CN Keywords Not Searchable in Example codelab

    Hi, I am a newbie and trying out riot.

    When I run

    ........github.com/go-ego/riot/examples/codelab]$ go run search_server.go
    

    I found out many Chinese phrase (text/keywords) didn't return any results. For example, I can get results from the keywords and 中国. But when I tried 中秋, 国庆, 企业, 企业家 etc., there is nothing returned. Then I tried a person name 李小龙, and there is no result either. I also saw the target index document had the context ...... @薛蛮子: ......, then I tried the keyword 薛蛮子, still no result. I don't really understand because the words 薛蛮子 is separated between two punctuation and should be easily searchable from what I feel.

    Since I am a newbie, I am wondering what causes these keywords can not return any results. The above keywords are just some examples. I tried more than that. Only small set of Chinese phrase (is that called text segmentation?) can be supported. The most keywords that I tried can not return anything. Is this due to a bad SegmenterDict dictionary.txt or project code?

    Btw I haven't read the doc and code in detail, so sorry if I am totally wrong. Thank you very much for the help.

    My Environment:

    $ dep status
    PROJECT                          CONSTRAINT     VERSION        REVISION  LATEST   PKGS USED
    github.com/AndreasBriese/bbloom  *              branch master  28f7e88   28f7e88  1   
    github.com/boltdb/bolt           *              v1.3.1         2f1ce7a   2f1ce7a  1   
    github.com/dgraph-io/badger      *              v1.0.1         89689ef   89689ef  6   
    github.com/dgryski/go-farm       *              branch master  e2d0fe2   e2d0fe2  1   
    github.com/go-ego/cedar          *              branch master  5ebe674   5ebe674  1   
    github.com/go-ego/gpy            *              branch master  66bb7e1   66bb7e1  1   
    github.com/go-ego/gse            *              branch master  b16cca4   b16cca4  1   
    github.com/go-ego/murmur         *              branch master  84b529b   84b529b  1   
    github.com/go-ego/riot           branch master  branch master  3431598   3431598  5   
    github.com/golang/protobuf       *              branch master  1643683   1643683  1   
    github.com/golang/snappy         *              branch master  553a641   553a641  1   
    github.com/pkg/errors            *              v0.8.0         645ef00   645ef00  1   
    github.com/shirou/gopsutil       *              v2.17.10       48fc561   48fc561  2   
    github.com/syndtr/goleveldb      *              branch master  549b6d6   549b6d6  12  
    golang.org/x/net                 *              branch master  a337091   a337091  3   
    golang.org/x/sys                 *              branch master  75813c6   4b45465  2
    
  • run simple exmaple error

    run simple exmaple error

    when i run the simplest_example, it shows the error below, which means cant load the dictionary. "2017/10/30 13:48:28 载入gse词典 github.com/go-ego/riot/data/dict/dictionary.txt 2017/10/30 13:48:28 无法载入字典文件 "github.com/go-ego/riot/data/dict/dictionary.txt"

  • 创建持久化索引,每分钟只能写3000-5000条数据,请问正常吗?Create a persistent index, only write 3000-5000 data per minute. Is it normal?

    创建持久化索引,每分钟只能写3000-5000条数据,请问正常吗?Create a persistent index, only write 3000-5000 data per minute. Is it normal?

    使用的是微博搜索那个例子,将数据改为从自己数据库中搜索,但是写入的速度很慢,每分钟只能写入3000-5000条,已经使用了协程,不知道是不是哪里写错了。代码如下 Using the Weibo search example, the data is changed to search from my own database, but the write speed is very slow, only 3000-5000 can be written per minute. Correspondence has been used,I don't know where it was wrong.Code show as below

    for i := 0; i < 100; i++ {
    	go indexXwz(xwzs)
    }
    
    func indexXwz(xwzs <-chan Xwz) {
    	for xwz := range xwzs {
    		searcher.IndexDoc(xwz.Id, types.DocIndexData{
    			Content: xwz.Name,
    			Fields: XwzScoringFields{
    				Timestamp: xwz.LatestDate,
    				CountNum:  xwz.CountNum,
    			},
    		}, true)
    	}
            searcher.Flush()
    }
    
  • [Bug] DATA RACE while using storage.

    [Bug] DATA RACE while using storage.

    • Ego version (or commit ref): 726c143577246eb664d61405cdc4a06a8d0d2bc5
    • Go version: v1.9.2
    • Gcc version: Apple LLVM version 9.0.0 (clang-900.0.39.2)
    • Operating system and bit: macOS
    • Can you reproduce the bug at Examples:
      • Yes, running go build -race and ./store in examples/store/...
    • Log gist:

    Description

    While using go build -race and running with storage:

    2018/01/24 16:24:53 Load the gse dictionary ../../data/dict/dictionary.txt
    2018/01/24 16:25:15 gse dictionary loaded finished.
    ==================
    WARNING: DATA RACE
    Read at 0x000004b4c8c0 by main goroutine:
      github.com/go-ego/riot.(*Engine).FlushIndex()
          /go/src/github.com/go-ego/riot/engine.go:656 +0x78
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:60 +0x378
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    
    Previous write at 0x000004b4c8c0 by goroutine 162:
      sync/atomic.AddInt64()
          /usr/local/go/src/runtime/race_amd64.s:276 +0xb
      github.com/go-ego/riot.(*Engine).indexerAddDocWorker()
          /go/src/github.com/go-ego/riot/indexer_worker.go:52 +0x1a2
    
    Goroutine 162 (running) created at:
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:275 +0x831
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).Read()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:93 +0x64e
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    ==================
    ==================
    WARNING: DATA RACE
    Write at 0x000004b4c8c0 by goroutine 82:
      sync/atomic.AddInt64()
          /usr/local/go/src/runtime/race_amd64.s:276 +0xb
      github.com/go-ego/riot.(*Engine).indexerAddDocWorker()
          /go/src/github.com/go-ego/riot/indexer_worker.go:52 +0x1a2
    
    Previous read at 0x000004b4c8c0 by main goroutine:
      github.com/go-ego/riot.(*Engine).FlushIndex()
          /go/src/github.com/go-ego/riot/engine.go:656 +0x78
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:60 +0x378
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    
    Goroutine 82 (running) created at:
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:275 +0x831
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).Read()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:93 +0x64e
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    ==================
    ==================
    WARNING: DATA RACE
    Write at 0x000004b4c8c0 by goroutine 162:
      sync/atomic.AddInt64()
          /usr/local/go/src/runtime/race_amd64.s:276 +0xb
      github.com/go-ego/riot.(*Engine).indexerAddDocWorker()
          /go/src/github.com/go-ego/riot/indexer_worker.go:52 +0x1a2
    
    Previous read at 0x000004b4c8c0 by main goroutine:
      github.com/go-ego/riot.(*Engine).FlushIndex()
          /go/src/github.com/go-ego/riot/engine.go:656 +0x78
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:60 +0x378
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    
    Goroutine 162 (running) created at:
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:275 +0x831
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).Read()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:93 +0x64e
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    ==================
    ==================
    WARNING: DATA RACE
    Write at 0x000004b4c8f8 by goroutine 309:
      sync/atomic.AddInt64()
          /usr/local/go/src/runtime/race_amd64.s:276 +0xb
      github.com/go-ego/riot.(*Engine).storageIndexDocWorker()
          /go/src/github.com/go-ego/riot/storage_worker.go:52 +0x43e
    
    Previous read at 0x000004b4c8f8 by main goroutine:
      github.com/go-ego/riot.(*Engine).FlushIndex()
          /go/src/github.com/go-ego/riot/engine.go:658 +0x138
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:60 +0x378
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    
    Goroutine 309 (running) created at:
      github.com/go-ego/riot.(*Engine).Storage()
          /go/src/github.com/go-ego/riot/engine.go:216 +0xbb3
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:289 +0x8df
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).Read()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:93 +0x64e
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    ==================
    ==================
    WARNING: DATA RACE
    Write at 0x000004b4c8d0 by goroutine 42:
      sync/atomic.AddInt64()
          /usr/local/go/src/runtime/race_amd64.s:276 +0xb
      github.com/go-ego/riot.(*Engine).indexerAddDocWorker()
          /go/src/github.com/go-ego/riot/indexer_worker.go:55 +0x159
    
    Previous read at 0x000004b4c8d0 by main goroutine:
      github.com/go-ego/riot.(*Engine).FlushIndex()
          /go/src/github.com/go-ego/riot/engine.go:667 +0x21a
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:60 +0x378
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    
    Goroutine 42 (running) created at:
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:275 +0x831
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).Read()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:93 +0x64e
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    ==================
    ==================
    WARNING: DATA RACE
    Write at 0x000004b4c8d0 by goroutine 22:
      sync/atomic.AddInt64()
          /usr/local/go/src/runtime/race_amd64.s:276 +0xb
      github.com/go-ego/riot.(*Engine).indexerAddDocWorker()
          /go/src/github.com/go-ego/riot/indexer_worker.go:55 +0x159
    
    Previous read at 0x000004b4c8d0 by main goroutine:
      github.com/go-ego/riot.(*Engine).FlushIndex()
          /go/src/github.com/go-ego/riot/engine.go:667 +0x21a
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:60 +0x378
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    
    Goroutine 22 (running) created at:
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:275 +0x831
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).Read()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:93 +0x64e
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    ==================
    ==================
    WARNING: DATA RACE
    Write at 0x000004b4c8d0 by goroutine 122:
      sync/atomic.AddInt64()
          /usr/local/go/src/runtime/race_amd64.s:276 +0xb
      github.com/go-ego/riot.(*Engine).indexerAddDocWorker()
          /go/src/github.com/go-ego/riot/indexer_worker.go:55 +0x159
    
    Previous read at 0x000004b4c8d0 by main goroutine:
      github.com/go-ego/riot.(*Engine).FlushIndex()
          /go/src/github.com/go-ego/riot/engine.go:667 +0x21a
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:60 +0x378
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    
    Goroutine 122 (running) created at:
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:275 +0x831
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).Read()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:93 +0x64e
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    ==================
    ==================
    WARNING: DATA RACE
    Write at 0x000004b4c8d0 by goroutine 82:
      sync/atomic.AddInt64()
          /usr/local/go/src/runtime/race_amd64.s:276 +0xb
      github.com/go-ego/riot.(*Engine).indexerAddDocWorker()
          /go/src/github.com/go-ego/riot/indexer_worker.go:55 +0x159
    
    Previous read at 0x000004b4c8d0 by main goroutine:
      github.com/go-ego/riot.(*Engine).FlushIndex()
          /go/src/github.com/go-ego/riot/engine.go:667 +0x21a
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:60 +0x378
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    
    Goroutine 82 (running) created at:
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:275 +0x831
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).Read()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:93 +0x64e
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    ==================
    ==================
    WARNING: DATA RACE
    Write at 0x000004b4c8d0 by goroutine 102:
      sync/atomic.AddInt64()
          /usr/local/go/src/runtime/race_amd64.s:276 +0xb
      github.com/go-ego/riot.(*Engine).indexerAddDocWorker()
          /go/src/github.com/go-ego/riot/indexer_worker.go:55 +0x159
    
    Previous read at 0x000004b4c8d0 by main goroutine:
      github.com/go-ego/riot.(*Engine).FlushIndex()
          /go/src/github.com/go-ego/riot/engine.go:667 +0x21a
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:60 +0x378
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    
    Goroutine 102 (running) created at:
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:275 +0x831
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).Read()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:93 +0x64e
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    ==================
    2018/01/24 16:25:20 recover index number: 3
    ==================
    WARNING: DATA RACE
    Read at 0x00c420087f28 by goroutine 86:
      github.com/go-ego/riot/core.(*Indexer).Lookup()
          /go/src/github.com/go-ego/riot/core/indexer.go:333 +0xbc
      github.com/go-ego/riot.(*Engine).indexerLookupWorker()
          /go/src/github.com/go-ego/riot/indexer_worker.go:82 +0x8d8
    
    Previous write at 0x00c420087f28 by goroutine 82:
      github.com/go-ego/riot/core.(*Indexer).AddDocs()
          /go/src/github.com/go-ego/riot/core/indexer.go:220 +0x133f
      github.com/go-ego/riot/core.(*Indexer).AddDocToCache()
          /go/src/github.com/go-ego/riot/core/indexer.go:147 +0x8bc
      github.com/go-ego/riot.(*Engine).indexerAddDocWorker()
          /go/src/github.com/go-ego/riot/indexer_worker.go:48 +0x127
    
    Goroutine 86 (running) created at:
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:281 +0x774
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).Read()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:93 +0x64e
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    
    Goroutine 82 (running) created at:
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:275 +0x831
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).Read()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:93 +0x64e
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    ==================
    ==================
    WARNING: DATA RACE
    Read at 0x00c420088268 by goroutine 166:
      github.com/go-ego/riot/core.(*Indexer).Lookup()
          /go/src/github.com/go-ego/riot/core/indexer.go:333 +0xbc
      github.com/go-ego/riot.(*Engine).indexerLookupWorker()
          /go/src/github.com/go-ego/riot/indexer_worker.go:82 +0x8d8
    
    Previous write at 0x00c420088268 by goroutine 162:
      github.com/go-ego/riot/core.(*Indexer).AddDocs()
          /go/src/github.com/go-ego/riot/core/indexer.go:220 +0x133f
      github.com/go-ego/riot/core.(*Indexer).AddDocToCache()
          /go/src/github.com/go-ego/riot/core/indexer.go:147 +0x8bc
      github.com/go-ego/riot.(*Engine).indexerAddDocWorker()
          /go/src/github.com/go-ego/riot/indexer_worker.go:48 +0x127
    
    Goroutine 166 (running) created at:
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:281 +0x774
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).Read()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:93 +0x64e
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    
    Goroutine 162 (running) created at:
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:275 +0x831
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).Read()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:93 +0x64e
      github.com/go-ego/riot/vendor/github.com/go-ego/gse.(*Segmenter).LoadDict()
          /go/src/github.com/go-ego/riot/vendor/github.com/go-ego/gse/segmenter.go:272 +0x35d
      github.com/go-ego/riot.(*Engine).Init()
          /go/src/github.com/go-ego/riot/engine.go:237 +0x9d2
      main.initEngine()
          /go/src/github.com/go-ego/riot/examples/store/main.go:34 +0x151
      main.main()
          /go/src/github.com/go-ego/riot/examples/store/main.go:89 +0x47
    ==================
    search--------- {[google testing] [{3 Google is testing another Search results layout with
            rounded cards, new colors, and the 4 mysterious colored dots again <nil> <nil> [0] [] []}] false 1} ; docs= [{3 Google is testing another Search results layout with
            rounded cards, new colors, and the 4 mysterious colored dots again <nil> <nil> [0] [] []}]
    Found 11 data race(s)
    
  • Patch segmenter of #51

    Patch segmenter of #51

    • Issues: #51

    Provide test code:

    // at engine_test.go:937 
    func TestSearchWithSetmenter(t *testing.T){
       // ...
    }
    

    Description

    Provide support for self defined segmenter without breaking current implement.

    ...

  • [SUGGEST] About vendor

    [SUGGEST] About vendor

    Not sure

    Just wondering why to keep all third lib source code in vendor directory? That case some dependence issue in my workspace, I think keep the vendor.json is enough ? Source code make the repo larger and keep extra source in project vendor.

    What I use is glide to config my project, I think it work well and recommend to you ~

  • Example returns no results

    Example returns no results

    This is the output

    2017/10/23 15:41:30 Check virtualMemory...
    Total: 8551211008, Free:0, UsedPercent:44.000000%
    2017/10/23 15:41:30 {[google testing] [] false 0}
    

    I dont think this is the right output.

  • Compiling error when use SearchID()

    Compiling error when use SearchID()

    • Riot version (or commit ref): v0.10.0.425
    • Go version: 1.12
    • Operating system and bit: linux (centos7.6)
    • Can you reproduce the bug at Examples:
      • [ ] Yes (provide example code)
      • [ ] No
      • [ ] Not relevant
    • Provide example code:
    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)
    
    	search1 := searcher.SearchID(req)
    	log.Println("search...", search1)
    
    	req = types.SearchReq{Text: "why"}
    	search = searcher.Search(req)
    	log.Println("search...", search)
    }
    
    

    Description

    Compiling error: '...github.com/go-ego/riot/engine.go:756:3: cannot use resp.Docs.(types.ScoredDocs) (type types.ScoredDocs) as type []types.ScoredID in field value'

  • fix build breakage caused by badger package update

    fix build breakage caused by badger package update

    found by gopkgs.io. example build log:

    https://gopkgs.io/builds/20180925-042129-6b841d77

    the breakage is caused by:

    https://github.com/dgraph-io/badger/commit/c10276c9d3b0c42744ed41b9177f4a9f021d8e08

  • Digital fuzzy query does not work

    Digital fuzzy query does not work

    1. Please speak English, this is the language everybody of us can speak and write.
    2. Please take a moment to search that an issue doesn't already exist.
    3. Please ask questions or config/deploy problems on our Gitter channel: https://gitter.im/go-ego/ego
    4. Please give all relevant information below for bug reports, incomplete details will be handled as an invalid report.

    You MUST delete the content above including this line before posting, otherwise your issue will be invalid.

    • Riot version (or commit ref): v0.0.0-20201013133145-f4c30acb3704
    • Go version: v1.15
    • Operating system and bit:
    • Can you reproduce the bug at Examples:
      • [ ] Yes (provide example code)
      • [ ] No
      • [ ] Not relevant
    • Provide example code:
            searcher := riot.Engine{}
    	searcher.Init(types.EngineOpts{
    		Using: 3,
    		//GseDict: "testdata/dictionary.txt",
    		IndexerOpts: &types.IndexerOpts{
    			IndexType: types.DocIdsIndex,
    		},
    	})
    	defer searcher.Close()
    
    	text := "《复仇者联盟3:无限战争》a123是全片使用IMAX摄影机拍摄"
    	text1 := "复仇:者在IMAX影院放222映时"
    	text2 := "全片以上下扩展至IMAX 1.9:1的宽高比来呈现"
    
    	text3 := "Google Is Experimenting With Virtual Reality Advertising"
    	text4 := `Google accidentally pushed Bluetooth update for Home
    	speaker early`
    	text5 := `Google is testing another Search results layout with 
    	rounded cards, new colors, and the 4 mysterious colored dots again`
    
    	//for i := 6; i < 10000; i++ {
    	//	in := strconv.Itoa(i)
    	//	content := fmt.Sprintf(format, i)
    	//	searcher.Index(in, types.DocData{
    	//		Content: content,
    	//	})
    	//}
    
    	// 将文档加入索引,docId 从0开始
    	searcher.Index("0", types.DocData{Content: text})
    	searcher.Index("1", types.DocData{Content: text1})
    	searcher.Index("2", types.DocData{Content: text2})
    	searcher.Index("3", types.DocData{Content: text3})
    	searcher.Index("4", types.DocData{Content: text4})
    	searcher.Index("5", types.DocData{Content: text5})
    
    	// 等待索引刷新完毕
    	searcher.Flush()
    
    	// 搜索输出格式见 types.SearchResp 结构体
    	result := searcher.Search(types.SearchReq{
    		Text: "123",
    	})
    	log.Print(result.NumDocs)
    	log.Print(result)
    
    • Log gist:
    2021/01/08 14:36:33 Dictionary file path is empty, load the default dictionary file.
    2021/01/08 14:36:33 Dict files path:  [/Users/zc/go/pkg/mod/github.com/go-ego/[email protected]/data/dict/dictionary.txt]
    2021/01/08 14:36:33 Load the gse dictionary: "/Users/zc/go/pkg/mod/github.com/go-ego/[email protected]/data/dict/dictionary.txt" 
    2021/01/08 14:36:35 Gse dictionary loaded finished.
    2021/01/08 14:36:35 Check virtualMemory...
    2021/01/08 14:36:35 Total: 17179869184, Free: 4401246208, UsedPercent: 51.322794%
    2021/01/08 14:36:35 0
    2021/01/08 14:36:35 {{[123] false 0} []}
    
    

    Description

    ...

  • TokenLoc out of length

    TokenLoc out of length

    • Riot version (or commit ref): 20201013133145-f4c30acb3704
    • Go version: go version go1.14.5 darwin/amd64
    • Operating system and bit: macOS 10.15.6
    • Can you reproduce the bug at Examples:
      • [x] Yes (provide example code)
      • [ ] No
      • [ ] Not relevant
    • Provide example code:
    package main
    
    import (
    	"log"
    
    	"github.com/go-ego/riot"
    	"github.com/go-ego/riot/types"
    )
    
    var (
    	searcher = riot.Engine{}
    )
    
    func init() {
    	initSearcher()
    	initIndex()
    }
    
    func initSearcher() {
    	searcher.Init(types.EngineOpts{
    		Using:   3,
    		GseDict: "zh",
    		IndexerOpts: &types.IndexerOpts{
    			IndexType: types.LocsIndex,
    		},
    	})
    }
    
    func initIndex() {
    	docID := "1"
    	content := "验证账户权限 运行一些简单的指令来验证账户的有效性 > show dbs admin 0.000GB config 0.000GB local 0.000GB > show users { \"_id\" : \"admin.admin\", \"userId\" : UUID(\"dc5760ea-c8c1-4f40-af5b-7d9d53779842\"), \"user\" : \"admin\", \"db\" : \"admin\", \"roles\" : [ { \"role\" : \"userAdminAnyDatabase\", \"db\" : \"admin\" } ], \"mechanisms\" : [ \"SCRAM-SHA-1\", \"SCRAM-SHA-256\" ] } "
    	searcher.Index(docID,
    		types.DocData{Content: content},
    	)
    	searcher.Flush()
    }
    
    func main() {
    	keyword := "t"
    
    	res := searcher.SearchDoc(types.SearchReq{Text: keyword})
    
    	log.Println("TokenLocs = ", res.Docs[0].TokenLocs)
    	log.Println("len(content) = ", len(res.Docs[0].Content))
    }
    
    • Log gist: 2020/12/20 13:39:33 Load the gse dictionary: "/Users/jabin/go/pkg/mod/github.com/go-ego/[email protected]/data/dict/dictionary.txt" 2020/12/20 13:39:34 Gse dictionary loaded finished. 2020/12/20 13:39:34 Check virtualMemory... 2020/12/20 13:39:34 Total: 17179869184, Free: 15147008, UsedPercent: 64.184594% 2020/12/20 13:39:34 TokenLocs = [[495]] 2020/12/20 13:39:34 len(content) = 376

    Description

    First TokenLoc is 495 but greater than len(content).

  • pressure test. after 10000 times request, out of memory.

    pressure test. after 10000 times request, out of memory.

    • Riot version (or commit ref):
    • Go version: v.0.10.0
    • Operating system and bit:
    • Can you reproduce the bug at Examples:
      • [ ] Yes (provide example code)
      • [ ] No
      • [ ] Not relevant
    • Provide example code: this is the code fo search: output := searcher.SearchDoc(types.SearchReq{ Text: query, //Tokens: text1, RankOpts: &types.RankOpts{ ScoringCriteria: &ArticleScoringCriteria{}, OutputOffset: (page-1)*count, MaxOutputs: count, }, })
    
    
    • Log gist:

    Description

    ...

  • File search example please

    File search example please

    Description

    All example that I saw are string-based searches. However, can riot somehow be used as/for a file-based search tool?

    Basically it'll be just like grep, but using its persistent index to speed up the searches, while supporting 中文分词 at the same time.

    The application scenario is that I have a huge collection of files in Chinese, thousands of them, thus I need something to search through them quickly, with the help of the pre-built indexes, as the content of the files will not be change (or very rarely), but more and more files are added daily. I haven't found any tools that does a good job in Chinese content search yet.

    Is it possible? if so, sample code appreciated.

    Thanks

  • grpc has been updated . But riot still uses Deprecated mesthods. Why not upgrade?

    grpc has been updated . But riot still uses Deprecated mesthods. Why not upgrade?

    riot\data\client\main.go `b := grpc.RoundRobin(r)

    ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) // defer cancel()

    conn, err := grpc.DialContext( ctx, *reg, grpc.WithInsecure(), grpc.WithBalancer(b), grpc.WithBlock())`

Distributed-Services - Distributed Systems with Golang to consequently build a fully-fletched distributed service

Distributed-Services This project is essentially a result of my attempt to under

Jun 1, 2022
CockroachDB - the open source, cloud-native distributed SQL database.
CockroachDB - the open source, cloud-native distributed SQL database.

CockroachDB is a cloud-native distributed SQL database designed to build, scale, and manage modern, data-intensive applications. What is CockroachDB?

Dec 29, 2022
Fast, efficient, and scalable distributed map/reduce system, DAG execution, in memory or on disk, written in pure Go, runs standalone or distributedly.

Gleam Gleam is a high performance and efficient distributed execution system, and also simple, generic, flexible and easy to customize. Gleam is built

Jan 1, 2023
💡 A Distributed and High-Performance Monitoring System. The next generation of Open-Falcon
💡 A Distributed and High-Performance Monitoring System.  The next generation of Open-Falcon

夜莺简介 夜莺是一套分布式高可用的运维监控系统,最大的特点是混合云支持,既可以支持传统物理机虚拟机的场景,也可以支持K8S容器的场景。同时,夜莺也不只是监控,还有一部分CMDB的能力、自动化运维的能力,很多公司都基于夜莺开发自己公司的运维平台。开源的这部分功能模块也是商业版本的一部分,所以可靠性有保

Jan 5, 2023
A distributed fault-tolerant order book matching engine
A distributed fault-tolerant order book matching engine

Go - Between A distributed fault-tolerant order book matching engine. Features Limit orders Market orders Order book depth Calculate market price for

Dec 24, 2021
Distributed lock manager. Warning: very hard to use it properly. Not because it's broken, but because distributed systems are hard. If in doubt, do not use this.

What Dlock is a distributed lock manager [1]. It is designed after flock utility but for multiple machines. When client disconnects, all his locks are

Dec 24, 2019
Distributed reliable key-value store for the most critical data of a distributed system

etcd Note: The main branch may be in an unstable or even broken state during development. For stable versions, see releases. etcd is a distributed rel

Dec 30, 2022
A simple but powerful distributed lock

nlock A simple but powerful distributed lock Get Started Download go get github.com/inuggets/nlock Usage Redis lock import lock "github.com/inuggets/

Nov 14, 2021
High performance, distributed and low latency publish-subscribe platform.
High performance, distributed and low latency publish-subscribe platform.

Emitter: Distributed Publish-Subscribe Platform Emitter is a distributed, scalable and fault-tolerant publish-subscribe platform built with MQTT proto

Jan 2, 2023
Dapr is a portable, event-driven, runtime for building distributed applications across cloud and edge.
Dapr is a portable, event-driven, runtime for building distributed applications across cloud and edge.

Dapr is a portable, serverless, event-driven runtime that makes it easy for developers to build resilient, stateless and stateful microservices that run on the cloud and edge and embraces the diversity of languages and developer frameworks.

Jan 5, 2023
Build share and run your distributed applications.
Build share and run your distributed applications.

sealer[ˈsiːlər] provides the way for distributed application package and delivery based on kubernetes.

Dec 30, 2022
short-url distributed and high-performance

durl 是一个分布式的高性能短链服务,逻辑简单,并提供了相关api接口,开发人员可以快速接入,也可以作为go初学者练手项目.

Jan 2, 2023
A distributed and coördination-free log management system
A distributed and coördination-free log management system

OK Log is archived I hoped to find the opportunity to continue developing OK Log after the spike of its creation. Unfortunately, despite effort, no su

Dec 26, 2022
JuiceFS is a distributed POSIX file system built on top of Redis and S3.
JuiceFS is a distributed POSIX file system built on top of Redis and S3.

JuiceFS is a high-performance POSIX file system released under GNU Affero General Public License v3.0. It is specially optimized for the cloud-native

Jan 4, 2023
Golimit is Uber ringpop based distributed and decentralized rate limiter
Golimit is Uber ringpop based distributed and decentralized rate limiter

Golimit A Distributed Rate limiter Golimit is Uber ringpop based distributed and decentralized rate limiter. It is horizontally scalable and is based

Dec 21, 2022
A distributed systems library for Kubernetes deployments built on top of spindle and Cloud Spanner.

hedge A library built on top of spindle and Cloud Spanner that provides rudimentary distributed computing facilities to Kubernetes deployments. Featur

Nov 9, 2022
A distributed locking library built on top of Cloud Spanner and TrueTime.

A distributed locking library built on top of Cloud Spanner and TrueTime.

Sep 13, 2022