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

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

Description

@oldfeel
  • 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?
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions