forked from blevesearch/bleve-bench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapping.go
44 lines (34 loc) · 1.24 KB
/
mapping.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package blevebench
import (
"github.com/blevesearch/bleve"
"github.com/blevesearch/bleve/mapping"
)
// BuildArticleMapping returns a mapping for indexing wikipedia articles
// in a manner similar to that done by lucene nightly benchmarks
func BuildArticleMapping() mapping.IndexMapping {
// a generic reusable mapping for english text
standardJustIndexed := bleve.NewTextFieldMapping()
standardJustIndexed.Store = false
standardJustIndexed.IncludeInAll = false
standardJustIndexed.IncludeTermVectors = false
standardJustIndexed.Analyzer = "standard"
keywordJustIndexed := bleve.NewTextFieldMapping()
keywordJustIndexed.Store = false
keywordJustIndexed.IncludeInAll = false
keywordJustIndexed.IncludeTermVectors = false
keywordJustIndexed.Analyzer = "keyword"
articleMapping := bleve.NewDocumentMapping()
// title
articleMapping.AddFieldMappingsAt("title",
keywordJustIndexed)
// text
articleMapping.AddFieldMappingsAt("text",
standardJustIndexed)
// _all (disabled)
disabledSection := bleve.NewDocumentDisabledMapping()
articleMapping.AddSubDocumentMapping("_all", disabledSection)
indexMapping := bleve.NewIndexMapping()
indexMapping.DefaultMapping = articleMapping
indexMapping.DefaultAnalyzer = "standard"
return indexMapping
}