Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Is it possible to search short sentences with long sentences #107

Open
oldfeel opened this issue May 11, 2020 · 0 comments
Open

Is it possible to search short sentences with long sentences #107

oldfeel opened this issue May 11, 2020 · 0 comments

Comments

@oldfeel
Copy link

oldfeel commented May 11, 2020

  • Riot version (or commit ref): 0.10.0
  • Go version: 1.14.2
  • Operating system and bit: windows amd64
  • Provide example code:
package main

import (
	"log"

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

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影复仇院放映时者"

	// 将文档加入索引,docId 从1开始
	searcher.Index("你好,世界", types.DocData{Content: text})
	searcher.Index("2", types.DocData{Content: text1}, false)

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

	// 搜索输出格式见 types.SearchResp 结构体
	log.Print(ofutils.ToJson(searcher.Search(types.SearchReq{Text: "复仇者大联盟"})))
	log.Print(ofutils.ToJson(searcher.Search(types.SearchReq{Text: "《复仇者联盟3:无限战争》是全片使用IMAX摄影机拍摄"})))
}
  • Log gist:

Description

I want to use Big Avengers to search for Avengers, can it?
...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant