bugfixes and updated go.mod
This commit is contained in:
parent
9424084a36
commit
6e317eb08b
300 changed files with 53136 additions and 9719 deletions
51
pkg/index/mapping.go
Normal file
51
pkg/index/mapping.go
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright (C) 2019 Marius Schellenberger
|
||||
|
||||
package index
|
||||
|
||||
import (
|
||||
"github.com/blevesearch/bleve"
|
||||
"github.com/blevesearch/bleve/analysis/analyzer/custom"
|
||||
"github.com/blevesearch/bleve/analysis/token/edgengram"
|
||||
"github.com/blevesearch/bleve/analysis/token/lowercase"
|
||||
"github.com/blevesearch/bleve/analysis/tokenizer/unicode"
|
||||
"github.com/blevesearch/bleve/mapping"
|
||||
)
|
||||
|
||||
func createMapping() (m *mapping.IndexMappingImpl, err error) {
|
||||
m = bleve.NewIndexMapping()
|
||||
|
||||
err = m.AddCustomTokenFilter("bigram_tokenfilter", map[string]interface{}{
|
||||
"type": edgengram.Name,
|
||||
"side": edgengram.FRONT,
|
||||
"min": 3.0,
|
||||
"max": 25.0,
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = m.AddCustomAnalyzer("fulltext_ngram", map[string]interface{}{
|
||||
"type": custom.Name,
|
||||
"tokenizer": unicode.Name,
|
||||
"token_filters": []string{
|
||||
lowercase.Name,
|
||||
"bigram_tokenfilter",
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
doc := bleve.NewDocumentMapping()
|
||||
ti := bleve.NewTextFieldMapping()
|
||||
ti.Analyzer = "fulltext_ngram"
|
||||
doc.AddFieldMappingsAt("title", ti)
|
||||
st := bleve.NewTextFieldMapping()
|
||||
st.Analyzer = "fulltext_ngram"
|
||||
doc.AddFieldMappingsAt("store_title", st)
|
||||
s := bleve.NewTextFieldMapping()
|
||||
s.Analyzer = "fulltext_ngram"
|
||||
doc.AddFieldMappingsAt("search", s)
|
||||
|
||||
m.AddDocumentMapping(docType, doc)
|
||||
return
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue