GoJieba Bluge support mod
Bluge is an indexing library for Go. created by the author of the Bleve project
go get github.com/ttys3/blugejieba
// var ana bluge.Analyzer
jieba := &analysis.Analyzer{
Tokenizer: NewJiebaTokenizer(gojieba.DICT_PATH, gojieba.HMM_PATH, gojieba.USER_DICT_PATH, gojieba.IDF_PATH, gojieba.STOP_WORDS_PATH),
}
// for write
doc := bluge.NewDocument(msg.Id).
AddField(bluge.NewTextField("name", "hello bluge").WithAnalyzer(jieba))
err = writer.Update(doc.ID(), doc)
// for read (query)
query := bluge.NewMatchQuery(q).SetField("name").SetAnalyzer(jieba)
request := bluge.NewTopNSearch(10, query).
WithStandardAggregations()
documentMatchIterator, err := reader.Search(context.Background(), request)
if err != nil {
log.Fatalf("error executing search: %v", err)
}
please see jieba_tokenizer_test.go
https://blugelabs.com/bluge/migration/