Documentation ¶
Index ¶
- type Indexer
- func (i *Indexer) Add(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, ...) (err error)
- func (i *Indexer) Remove(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, ...) (err error)
- func (i *Indexer) Search(ctx context.Context, uid gregor1.UID, query string, opts chat1.SearchOpts) ([]chat1.ChatConvSearchHit, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Indexer ¶
type Indexer struct { sync.Mutex globals.Contextified utils.DebugLabeler // contains filtered or unexported fields }
Indexer keeps an encrypted index of chat messages for all conversations to enable full inbox search locally. Data is stored in leveldb in the form:
(convID) -> { token: { msgID: (msgMetadata), ...}, ... }, ... -> ...
Where msgMetadata has information about the message which can be used to filter the search such as sender username or creation time. The workload is expected to be write heavy with keeping the index up to date.
func NewIndexer ¶
func (*Indexer) Add ¶
func (i *Indexer) Add(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, msg chat1.MessageUnboxed) (err error)
Add tokenizes the message content and creates/updates index keys for each token.
func (*Indexer) Remove ¶
func (i *Indexer) Remove(ctx context.Context, convID chat1.ConversationID, uid gregor1.UID, msg chat1.MessageUnboxed) (err error)
Remove tokenizes the message content and updates/removes index keys for each token.
func (*Indexer) Search ¶
func (i *Indexer) Search(ctx context.Context, uid gregor1.UID, query string, opts chat1.SearchOpts) ([]chat1.ChatConvSearchHit, error)
Search tokenizes the given query and finds the intersection of all matches for each token, returning (convID,msgID) pairs with match information.