feat: keep the materials index in sync and add bm:materials-reindex
- the materials admin syncs after create and update and removes after delete, once the save transaction commits (UseMaterialIndex, set at Boot) - POST and PUT /api/v1/bm/materials sync after the transaction, DELETE removes the document (its statement has no primary key, so no callback) - bm:materials-reindex [--fresh] [--if-configured] ensures the index and syncs every material; it refuses without an engine and runs nightly at 04:15 with --if-configured - TestMaterialSearchAgainstDatabase (Postgres) is written for the final verification phase
This commit is contained in:
@@ -5,13 +5,15 @@ import (
|
||||
"git.golem15.com/golem15/summercms/modules/beachcomber"
|
||||
_ "git.golem15.com/golem15/summercms/modules/beachcomber/typesense"
|
||||
"git.golem15.com/jakub/sm-bm-plugin/classes"
|
||||
"git.golem15.com/jakub/sm-bm-plugin/controllers"
|
||||
)
|
||||
|
||||
// wireSearch builds the app's beachcomber service (search.driver; the
|
||||
// typesense engine registers itself through the blank import), installs the
|
||||
// jz.bm-only Gate and the material indexer. The Gate is app-wide, so it is
|
||||
// on only for contexts jz.bm marks: golem15.chatchannels' message syncs stay
|
||||
// off and chat messages never reach the index.
|
||||
// jz.bm-only Gate and the material indexer, which the API handlers and the
|
||||
// materials admin hooks use. The Gate is app-wide, so it is on only for
|
||||
// contexts jz.bm marks: golem15.chatchannels' message syncs stay off and
|
||||
// chat messages never reach the index.
|
||||
func (p *Plugin) wireSearch(app *backpack.App) error {
|
||||
svc, err := beachcomber.From(app)
|
||||
if err != nil {
|
||||
@@ -19,5 +21,6 @@ func (p *Plugin) wireSearch(app *backpack.App) error {
|
||||
}
|
||||
svc.SetGate(classes.MaterialSearchGate())
|
||||
p.materialIndex = classes.NewMaterialIndexer(app)
|
||||
controllers.UseMaterialIndex(p.materialIndex)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user