vcaesar / gse-bleve

Go use bleve with gse tokenizer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gse-bleve

Build Status Build Status CircleCI Status codecov Go Report Card GoDoc Release

Use

package main

import (
	"fmt"
	"os"

	"github.com/blevesearch/bleve/v2"
	gse "github.com/vcaesar/gse-bleve"
)

func main() {
	opt := gse.Option{
		Index: "test.blv",
		Dicts: "embed, ja",
		// Dicts: "embed, zh", 
		Stop: "",
		Opt: "search-hmm", 
		Trim: "trim",
		}

	index, err := gse.New(opt)
	if err != nil {
		fmt.Println("new mapping error is: ", err)
		return
	}

	text := `見解では、謙虚なヴォードヴィリアンのベテランは、運命の犠牲者と悪役の両方の変遷として代償を払っています`
	err = index.Index("1", text)
	index.Index("3", text+"浮き沈み")
	index.Index("4", `In view, a humble vaudevillian veteran cast vicariously as both victim and villain vicissitudes of fate.`)
	index.Index("2", `It's difficult to understand the sum of a person's life.`)
	if err != nil {
		fmt.Println("index error: ", err)
	}

	query := "運命の犠牲者"
	req := bleve.NewSearchRequest(bleve.NewQueryStringQuery(query))
	req.Highlight = bleve.NewHighlight()
	res, err := index.Search(req)
	fmt.Println(res, err)

	os.RemoveAll("test.blv")
}

About

Go use bleve with gse tokenizer

License:BSD 2-Clause "Simplified" License


Languages

Language:Go 100.0%