search

package
v0.0.0-...-a8b6a46 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2020 License: BSD-3-Clause, BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

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 NewIndexer(g *globals.Context) *Indexer

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL