Persist the search index on disk

This commit is contained in:
André Duffeck
2022-04-25 16:00:25 +02:00
parent 51cf27d767
commit 1a84afc401
3 changed files with 12 additions and 2 deletions
+1
View File
@@ -18,6 +18,7 @@ type Config struct {
GRPC GRPC `ocisConfig:"grpc"`
Datapath string `yaml:"data_path" env:"SEARCH_DATA_PATH"`
Reva Reva `ocisConfig:"reva"`
TokenManager TokenManager `ocisConfig:"token_manager"`
Events Events `yaml:"events"`
@@ -1,7 +1,10 @@
package defaults
import (
"path"
"github.com/owncloud/ocis/extensions/search/pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/defaults"
)
func DefaultConfig() *config.Config {
@@ -17,6 +20,7 @@ func DefaultConfig() *config.Config {
Service: config.Service{
Name: "search",
},
Datapath: path.Join(defaults.BaseDataPath(), "search"),
Reva: config.Reva{
Address: "127.0.0.1:9142",
},
+7 -2
View File
@@ -3,6 +3,7 @@ package service
import (
"context"
"errors"
"path/filepath"
"github.com/blevesearch/bleve/v2"
revactx "github.com/cs3org/reva/v2/pkg/ctx"
@@ -42,9 +43,13 @@ func NewHandler(opts ...Option) (searchsvc.SearchProviderHandler, error) {
return nil, err
}
bleveIndex, err := bleve.NewMemOnly(index.BuildMapping())
indexDir := filepath.Join(cfg.Datapath, "index.bleve")
bleveIndex, err := bleve.Open(indexDir)
if err != nil {
return nil, err
bleveIndex, err = bleve.New(indexDir, index.BuildMapping())
if err != nil {
return nil, err
}
}
index, err := index.New(bleveIndex)
if err != nil {