mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-25 13:38:19 -05:00
Persist the search index on disk
This commit is contained in:
@@ -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",
|
||||
},
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user