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
|
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
|
// IndexElement describes the layout of an element to index
|
||||||
type IndexElement struct {
|
type IndexElement struct {
|
||||||
EventID string
|
EventID string
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,9 @@
|
||||||
package fulltext
|
package fulltext
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/matrix-org/dendrite/setup/config"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/setup/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Search struct{}
|
type Search struct{}
|
||||||
|
|
@ -28,6 +29,13 @@ type IndexElement struct {
|
||||||
StreamPosition int64
|
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 {
|
type SearchResult struct {
|
||||||
Status interface{} `json:"status"`
|
Status interface{} `json:"status"`
|
||||||
Request *interface{} `json:"request"`
|
Request *interface{} `json:"request"`
|
||||||
|
|
@ -48,7 +56,7 @@ func (f *Search) Close() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Search) Index(e IndexElement) error {
|
func (f *Search) Index(e ...IndexElement) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ type OutputClientDataConsumer struct {
|
||||||
stream streams.StreamProvider
|
stream streams.StreamProvider
|
||||||
notifier *notifier.Notifier
|
notifier *notifier.Notifier
|
||||||
serverName gomatrixserverlib.ServerName
|
serverName gomatrixserverlib.ServerName
|
||||||
fts *fulltext.Search
|
fts fulltext.Indexer
|
||||||
cfg *config.SyncAPI
|
cfg *config.SyncAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ type OutputRoomEventConsumer struct {
|
||||||
pduStream streams.StreamProvider
|
pduStream streams.StreamProvider
|
||||||
inviteStream streams.StreamProvider
|
inviteStream streams.StreamProvider
|
||||||
notifier *notifier.Notifier
|
notifier *notifier.Notifier
|
||||||
fts *fulltext.Search
|
fts fulltext.Indexer
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewOutputRoomEventConsumer creates a new OutputRoomEventConsumer. Call Start() to begin consuming from room servers.
|
// NewOutputRoomEventConsumer creates a new OutputRoomEventConsumer. Call Start() to begin consuming from room servers.
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ func Setup(
|
||||||
rsAPI api.SyncRoomserverAPI,
|
rsAPI api.SyncRoomserverAPI,
|
||||||
cfg *config.SyncAPI,
|
cfg *config.SyncAPI,
|
||||||
lazyLoadCache caching.LazyLoadCache,
|
lazyLoadCache caching.LazyLoadCache,
|
||||||
fts *fulltext.Search,
|
fts fulltext.Indexer,
|
||||||
) {
|
) {
|
||||||
v1unstablemux := csMux.PathPrefix("/{apiversion:(?:v1|unstable)}/").Subrouter()
|
v1unstablemux := csMux.PathPrefix("/{apiversion:(?:v1|unstable)}/").Subrouter()
|
||||||
v3mux := csMux.PathPrefix("/{apiversion:(?:r0|v3)}/").Subrouter()
|
v3mux := csMux.PathPrefix("/{apiversion:(?:r0|v3)}/").Subrouter()
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// nolint:gocyclo
|
// 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()
|
start := time.Now()
|
||||||
var (
|
var (
|
||||||
searchReq SearchRequest
|
searchReq SearchRequest
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue