decentral1se
2 years ago
No known key found for this signature in database
GPG Key ID: 3789458B3D0C410
1 changed files with
11 additions and
3 deletions
-
exp/bleve.go
|
|
@ -8,6 +8,8 @@ import ( |
|
|
|
"strings" |
|
|
|
|
|
|
|
"github.com/blevesearch/bleve/v2" |
|
|
|
"github.com/blevesearch/bleve/v2/analysis/lang/en" |
|
|
|
"github.com/blevesearch/bleve/v2/search/highlight/highlighter/ansi" |
|
|
|
pdf "github.com/johbar/go-poppler" |
|
|
|
) |
|
|
|
|
|
|
@ -36,8 +38,10 @@ func main() { |
|
|
|
// create or open a bleve index
|
|
|
|
var index bleve.Index |
|
|
|
var err error |
|
|
|
mapping := bleve.NewIndexMapping() |
|
|
|
index, err = bleve.New("test.bleve", mapping) |
|
|
|
idxMap := bleve.NewIndexMapping() |
|
|
|
idxMap.DefaultAnalyzer = en.AnalyzerName |
|
|
|
|
|
|
|
index, err = bleve.New("test.bleve", idxMap) |
|
|
|
if err != nil { |
|
|
|
index, err = bleve.Open("test.bleve") |
|
|
|
if err != nil { |
|
|
@ -86,8 +90,12 @@ func main() { |
|
|
|
} |
|
|
|
|
|
|
|
// query for something! change the string to test other possibilities
|
|
|
|
query := bleve.NewMatchQuery("Enhanced-Page-Mode") |
|
|
|
query := bleve.NewMatchQuery("slew rate") |
|
|
|
|
|
|
|
search := bleve.NewSearchRequest(query) |
|
|
|
search.Highlight = bleve.NewHighlightWithStyle(ansi.Name) |
|
|
|
search.Size = 5 |
|
|
|
|
|
|
|
searchResults, err := index.Search(search) |
|
|
|
if err != nil { |
|
|
|
log.Fatal(err) |
|
|
|