go-ego / riot
- вторник, 24 октября 2017 г. в 03:13:57
Go Open Source, Distributed, Simple and efficient Search Engine
Go version >= 1.8
go get -u github.com/go-ego/riot
go get -u github.com/go-ego/re
To create a new riot application
$ re riot my-riotapp
To run the application we just created, you can navigate to the application folder and execute:
$ cd my-riotapp && re run
Look at an example(simplest_example.go)
package main
import (
"log"
"github.com/go-ego/riot/engine"
"github.com/go-ego/riot/types"
)
var (
// searcher is coroutine safe
searcher = engine.Engine{}
)
func main() {
// Init
searcher.Init(types.EngineInitOptions{
Using: 5,
NotUsingSegmenter: true})
defer searcher.Close()
// Add the document to the index, docId starts at 1
searcher.IndexDocument(1, types.DocIndexData{Content: "Google Is Experimenting With Virtual Reality Advertising"}, false)
searcher.IndexDocument(2, types.DocIndexData{Content: "Google accidentally pushed Bluetooth update for Home speaker early"}, false)
searcher.IndexDocument(3, types.DocIndexData{Content: "Google is testing another Search results layout with rounded cards, new colors, and the 4 mysterious colored dots again"}, false)
// Wait for the index to refresh
searcher.FlushIndex()
// The search output format is found in the types.SearchResponse structure
log.Print(searcher.Search(types.SearchRequest{Text:"google testing"}))
}
It is very simple!
Supporting riot, buy me a coffee.
Donate money by paypal to my account vzvway@gmail.com
Riot is primarily distributed under the terms of the Apache License (Version 2.0), base on wukong.