mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
Create Indexer interface
This commit is contained in:
parent
8c404440ef
commit
e493f4e800
|
|
@ -55,6 +55,13 @@ type Search struct {
|
|||
FulltextIndex bleve.Index
|
||||
}
|
||||
|
||||
type Indexer interface {
|
||||
Index(elements ...IndexElement) error
|
||||
Delete(eventID string) error
|
||||
Search(term string, roomIDs, keys []string, limit, from int, orderByStreamPos bool) (*bleve.SearchResult, error)
|
||||
Close() error
|
||||
}
|
||||
|
||||
// IndexElement describes the layout of an element to index
|
||||
type IndexElement struct {
|
||||
EventID string
|
||||
|
|
|
|||
|
|
@ -15,8 +15,9 @@
|
|||
package fulltext
|
||||
|
||||
import (
|
||||
"github.com/matrix-org/dendrite/setup/config"
|
||||
"time"
|
||||
|
||||
"github.com/matrix-org/dendrite/setup/config"
|
||||
)
|
||||
|
||||
type Search struct{}
|
||||
|
|
@ -28,6 +29,13 @@ type IndexElement struct {
|
|||
StreamPosition int64
|
||||
}
|
||||
|
||||
type Indexer interface {
|
||||
Index(elements ...IndexElement) error
|
||||
Delete(eventID string) error
|
||||
Search(term string, roomIDs, keys []string, limit, from int, orderByStreamPos bool) (SearchResult, error)
|
||||
Close() error
|
||||
}
|
||||
|
||||
type SearchResult struct {
|
||||
Status interface{} `json:"status"`
|
||||
Request *interface{} `json:"request"`
|
||||
|
|
@ -48,7 +56,7 @@ func (f *Search) Close() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (f *Search) Index(e IndexElement) error {
|
||||
func (f *Search) Index(e ...IndexElement) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ type OutputClientDataConsumer struct {
|
|||
stream streams.StreamProvider
|
||||
notifier *notifier.Notifier
|
||||
serverName gomatrixserverlib.ServerName
|
||||
fts *fulltext.Search
|
||||
fts fulltext.Indexer
|
||||
cfg *config.SyncAPI
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ type OutputRoomEventConsumer struct {
|
|||
pduStream streams.StreamProvider
|
||||
inviteStream streams.StreamProvider
|
||||
notifier *notifier.Notifier
|
||||
fts *fulltext.Search
|
||||
fts fulltext.Indexer
|
||||
}
|
||||
|
||||
// NewOutputRoomEventConsumer creates a new OutputRoomEventConsumer. Call Start() to begin consuming from room servers.
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ func Setup(
|
|||
rsAPI api.SyncRoomserverAPI,
|
||||
cfg *config.SyncAPI,
|
||||
lazyLoadCache caching.LazyLoadCache,
|
||||
fts *fulltext.Search,
|
||||
fts fulltext.Indexer,
|
||||
) {
|
||||
v1unstablemux := csMux.PathPrefix("/{apiversion:(?:v1|unstable)}/").Subrouter()
|
||||
v3mux := csMux.PathPrefix("/{apiversion:(?:r0|v3)}/").Subrouter()
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import (
|
|||
)
|
||||
|
||||
// nolint:gocyclo
|
||||
func Search(req *http.Request, device *api.Device, syncDB storage.Database, fts *fulltext.Search, from *string) util.JSONResponse {
|
||||
func Search(req *http.Request, device *api.Device, syncDB storage.Database, fts fulltext.Indexer, from *string) util.JSONResponse {
|
||||
start := time.Now()
|
||||
var (
|
||||
searchReq SearchRequest
|
||||
|
|
|
|||
Loading…
Reference in a new issue