feat: search materials through beachcomber
- Material is a beachcomber Searchable (index jz_bm_materials) in the hand-written models/material_search.go; jz.bm requires summercms v0.6.4 - classes.MaterialIndexer asks Typesense for up to 250 candidates with body highlights; the app-wide Gate is on only for jz.bm-marked contexts - GET /_bm/api/v1/materials takes q: candidates are re-gated, counted and paged in SQL in rank order, each row with at most one plain snippet - search failure answers 503 Search is unavailable.; without q the list is unchanged
This commit is contained in:
23
search.go
Normal file
23
search.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package bm
|
||||
|
||||
import (
|
||||
"git.golem15.com/golem15/summercms/modules/backpack"
|
||||
"git.golem15.com/golem15/summercms/modules/beachcomber"
|
||||
_ "git.golem15.com/golem15/summercms/modules/beachcomber/typesense"
|
||||
"git.golem15.com/jakub/sm-bm-plugin/classes"
|
||||
)
|
||||
|
||||
// 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.
|
||||
func (p *Plugin) wireSearch(app *backpack.App) error {
|
||||
svc, err := beachcomber.From(app)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
svc.SetGate(classes.MaterialSearchGate())
|
||||
p.materialIndex = classes.NewMaterialIndexer(app)
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user