[MM-20979] Add first implementation of the Bleve search engine (#14562)
* [MM-20979] Add first implementation of the Bleve search engine * Fix i18n * Migrate searchengine utils tests * Fix linter * Don't add allTermsQ if both termQueries and notTermQueries are empty * Fix test that should work if user is system admin * Modify naming according to review comments * Abstract getIndexDir function * Extracting bleve engine name as a constant * Merge both Indexer interfaces into one * Add worker stopped message * Allow worker to be started/stopped with config change * Use constants for index names * Modify test order * Fix linter * Trying to unlock the CI
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8d0343d2eb
Коммит
0154b8059b
@@ -98,6 +98,9 @@ func (s *Server) initJobs() {
|
||||
if jobsPluginsInterface != nil {
|
||||
s.Jobs.Plugins = jobsPluginsInterface(s.FakeApp())
|
||||
}
|
||||
if jobsBleveIndexerInterface != nil {
|
||||
s.Jobs.BleveIndexer = jobsBleveIndexerInterface(s)
|
||||
}
|
||||
s.Jobs.Workers = s.Jobs.InitWorkers()
|
||||
s.Jobs.Schedulers = s.Jobs.InitSchedulers()
|
||||
}
|
||||
|
||||
@@ -782,6 +782,7 @@ type AppIface interface {
|
||||
ProcessSlackText(text string) string
|
||||
Publish(message *model.WebSocketEvent)
|
||||
PublishSkipClusterSend(message *model.WebSocketEvent)
|
||||
PurgeBleveIndexes() *model.AppError
|
||||
PurgeElasticsearchIndexes() *model.AppError
|
||||
ReadFile(path string) ([]byte, *model.AppError)
|
||||
RecycleDatabaseConnection()
|
||||
|
||||
@@ -60,9 +60,9 @@ func RegisterJobsElasticsearchAggregatorInterface(f func(*Server) ejobs.Elastics
|
||||
jobsElasticsearchAggregatorInterface = f
|
||||
}
|
||||
|
||||
var jobsElasticsearchIndexerInterface func(*Server) ejobs.ElasticsearchIndexerInterface
|
||||
var jobsElasticsearchIndexerInterface func(*Server) tjobs.IndexerJobInterface
|
||||
|
||||
func RegisterJobsElasticsearchIndexerInterface(f func(*Server) ejobs.ElasticsearchIndexerInterface) {
|
||||
func RegisterJobsElasticsearchIndexerInterface(f func(*Server) tjobs.IndexerJobInterface) {
|
||||
jobsElasticsearchIndexerInterface = f
|
||||
}
|
||||
|
||||
@@ -84,6 +84,12 @@ func RegisterJobsPluginsJobInterface(f func(*App) tjobs.PluginsJobInterface) {
|
||||
jobsPluginsInterface = f
|
||||
}
|
||||
|
||||
var jobsBleveIndexerInterface func(*Server) tjobs.IndexerJobInterface
|
||||
|
||||
func RegisterJobsBleveIndexerInterface(f func(*Server) tjobs.IndexerJobInterface) {
|
||||
jobsBleveIndexerInterface = f
|
||||
}
|
||||
|
||||
var ldapInterface func(*App) einterfaces.LdapInterface
|
||||
|
||||
func RegisterLdapInterface(f func(*App) einterfaces.LdapInterface) {
|
||||
|
||||
@@ -10856,6 +10856,28 @@ func (a *OpenTracingAppLayer) PublishSkipClusterSend(message *model.WebSocketEve
|
||||
a.app.PublishSkipClusterSend(message)
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) PurgeBleveIndexes() *model.AppError {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.PurgeBleveIndexes")
|
||||
|
||||
a.ctx = newCtx
|
||||
a.app.Srv().Store.SetContext(newCtx)
|
||||
defer func() {
|
||||
a.app.Srv().Store.SetContext(origCtx)
|
||||
a.ctx = origCtx
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0 := a.app.PurgeBleveIndexes()
|
||||
|
||||
if resultVar0 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar0))
|
||||
ext.Error.Set(span, true)
|
||||
}
|
||||
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) PurgeElasticsearchIndexes() *model.AppError {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.PurgeElasticsearchIndexes")
|
||||
|
||||
@@ -32,19 +32,31 @@ func (a *App) TestElasticsearch(cfg *model.Config) *model.AppError {
|
||||
}
|
||||
|
||||
func (a *App) PurgeElasticsearchIndexes() *model.AppError {
|
||||
seI := a.SearchEngine().ElasticsearchEngine
|
||||
if seI == nil {
|
||||
engine := a.SearchEngine().ElasticsearchEngine
|
||||
if engine == nil {
|
||||
err := model.NewAppError("PurgeElasticsearchIndexes", "ent.elasticsearch.test_config.license.error", nil, "", http.StatusNotImplemented)
|
||||
return err
|
||||
}
|
||||
|
||||
if err := seI.PurgeIndexes(); err != nil {
|
||||
if err := engine.PurgeIndexes(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) PurgeBleveIndexes() *model.AppError {
|
||||
engine := a.SearchEngine().BleveEngine
|
||||
if engine == nil {
|
||||
err := model.NewAppError("PurgeBleveIndexes", "searchengine.bleve.disabled.error", nil, "", http.StatusNotImplemented)
|
||||
return err
|
||||
}
|
||||
if err := engine.PurgeIndexes(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SetSearchEngine(se *searchengine.Broker) {
|
||||
a.searchEngine = se
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/services/httpservice"
|
||||
"github.com/mattermost/mattermost-server/v5/services/imageproxy"
|
||||
"github.com/mattermost/mattermost-server/v5/services/searchengine"
|
||||
"github.com/mattermost/mattermost-server/v5/services/searchengine/bleveengine"
|
||||
"github.com/mattermost/mattermost-server/v5/services/timezones"
|
||||
"github.com/mattermost/mattermost-server/v5/services/tracing"
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
@@ -225,7 +226,13 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
return nil, errors.Wrapf(err, "unable to load Mattermost translation files")
|
||||
}
|
||||
|
||||
s.SearchEngine = searchengine.NewBroker(s.Config(), s.Jobs)
|
||||
searchEngine := searchengine.NewBroker(s.Config(), s.Jobs)
|
||||
bleveEngine := bleveengine.NewBleveEngine(s.Config(), s.Jobs)
|
||||
if err := bleveEngine.Start(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
searchEngine.RegisterBleveEngine(bleveEngine)
|
||||
s.SearchEngine = searchEngine
|
||||
|
||||
// at the moment we only have this implementation
|
||||
// in the future the cache provider will be built based on the loaded config
|
||||
@@ -237,8 +244,7 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
s.seenPendingPostIdsCache = s.CacheProvider.NewCache(PENDING_POST_IDS_CACHE_SIZE)
|
||||
s.statusCache = s.CacheProvider.NewCache(model.STATUS_CACHE_SIZE)
|
||||
|
||||
err := s.RunOldAppInitialization()
|
||||
if err != nil {
|
||||
if err := s.RunOldAppInitialization(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -985,6 +991,9 @@ func (s *Server) stopSearchEngine() {
|
||||
if s.SearchEngine != nil && s.SearchEngine.ElasticsearchEngine != nil && s.SearchEngine.ElasticsearchEngine.IsActive() {
|
||||
s.SearchEngine.ElasticsearchEngine.Stop()
|
||||
}
|
||||
if s.SearchEngine != nil && s.SearchEngine.BleveEngine != nil && s.SearchEngine.BleveEngine.IsActive() {
|
||||
s.SearchEngine.BleveEngine.Stop()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) initDiagnostics(endpoint string) {
|
||||
|
||||
Ссылка в новой задаче
Block a user