diff options
Diffstat (limited to 'internal')
-rw-r--r-- | internal/index/indexer.go | 12 | ||||
-rw-r--r-- | internal/nix/importable.go | 7 |
2 files changed, 18 insertions, 1 deletions
diff --git a/internal/index/indexer.go b/internal/index/indexer.go index da2fab3..a661b61 100644 --- a/internal/index/indexer.go +++ b/internal/index/indexer.go @@ -101,7 +101,17 @@ func createIndexMapping() (mapping.IndexMapping, error) { optionMapping.AddSubDocumentMapping("Default", nixValueMapping) optionMapping.AddSubDocumentMapping("Example", nixValueMapping) + packageMapping := bleve.NewDocumentStaticMapping() + + packageMapping.AddFieldMappingsAt("Name", keywordFieldMapping) + packageMapping.AddFieldMappingsAt("Source", keywordFieldMapping) + packageMapping.AddFieldMappingsAt("Description", textFieldMapping) + packageMapping.AddFieldMappingsAt("MainProgram", keywordFieldMapping) + packageMapping.AddFieldMappingsAt("PackageSet", keywordFieldMapping) + packageMapping.AddFieldMappingsAt("Platforms", keywordFieldMapping) + indexMapping.AddDocumentMapping("option", optionMapping) + indexMapping.AddDocumentMapping("package", packageMapping) return indexMapping, nil } @@ -259,7 +269,7 @@ func (i *WriteIndex) Import( var data bytes.Buffer enc := gob.NewEncoder(&data) - err = enc.Encode(obj) + err = enc.Encode(&obj) if err != nil { errs <- errors.WithMessage(err, "could not store object in search index") diff --git a/internal/nix/importable.go b/internal/nix/importable.go index 309ec5f..37532cd 100644 --- a/internal/nix/importable.go +++ b/internal/nix/importable.go @@ -1,5 +1,7 @@ package nix +import "encoding/gob" + type Importable interface { BleveType() string GetName() string @@ -9,3 +11,8 @@ type Importable interface { func GetKey(i Importable) string { return i.BleveType() + "/" + i.GetSource() + "/" + i.GetName() } + +func init() { + gob.Register(Option{}) + gob.Register(Package{}) +} |