diff options
author | Michael Muré <batolettre@gmail.com> | 2022-12-19 16:12:49 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2022-12-19 18:09:37 +0100 |
commit | 60d40d60e9f91247b61f541888f1469bff44f573 (patch) | |
tree | a3cdfd90a06358e7648a4a85a36cee680e121642 /repository/repo.go | |
parent | 3b62fe0a4c7b3f1ae4f9a163b6c483444b5a8d20 (diff) | |
download | git-bug-60d40d60e9f91247b61f541888f1469bff44f573.tar.gz |
repo: proper reduced interface for full-text indexing
Additionally, remove and concentrate quite a lot of complexity from the cache layer
into a "per app" single site where to configure how indexing is done.
Diffstat (limited to 'repository/repo.go')
-rw-r--r-- | repository/repo.go | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/repository/repo.go b/repository/repo.go index 2f90b437..42ed194c 100644 --- a/repository/repo.go +++ b/repository/repo.go @@ -6,7 +6,6 @@ import ( "io" "github.com/ProtonMail/go-crypto/openpgp" - "github.com/blevesearch/bleve" "github.com/go-git/go-billy/v5" "github.com/MichaelMure/git-bug/util/lamport" @@ -25,7 +24,7 @@ type Repo interface { RepoKeyring RepoCommon RepoStorage - RepoBleve + RepoIndex RepoData Close() error @@ -81,13 +80,33 @@ type RepoStorage interface { LocalStorage() billy.Filesystem } -// RepoBleve give access to Bleve to implement full-text search indexes. -type RepoBleve interface { - // GetBleveIndex return a bleve.Index that can be used to index documents - GetBleveIndex(name string) (bleve.Index, error) +// RepoIndex gives access to full-text search indexes +type RepoIndex interface { + GetIndex(name string) (Index, error) +} + +// Index is a full-text search index +type Index interface { + // IndexOne indexes one document, for the given ID. If the document already exist, + // it replaces it. + IndexOne(id string, texts []string) error + + // IndexBatch start a batch indexing. The returned indexer function is used the same + // way as IndexOne, and the closer function complete the batch insertion. + IndexBatch() (indexer func(id string, texts []string) error, closer func() error) + + // Search returns the list of IDs matching the given terms. + Search(terms []string) (ids []string, err error) - // ClearBleveIndex will wipe the given index - ClearBleveIndex(name string) error + // DocCount returns the number of document in the index. + DocCount() (uint64, error) + + // Clear empty the index. + Clear() error + + // Close closes the index and make sure everything is safely written. After this call + // the index can't be used anymore. + Close() error } type Commit struct { |