code

package
v1.11.7 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: MIT Imports: 28 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWrappedIndexerClosed = fmt.Errorf("Indexer closed before ready")

ErrWrappedIndexerClosed is the error returned if the indexer was closed before it was ready

Functions

func DeleteRepoFromIndexer

func DeleteRepoFromIndexer(repo *models.Repository, watchers ...chan<- error)

DeleteRepoFromIndexer remove all of a repository's entries from the indexer

func Init

func Init()

Init initialize the repo indexer

func UpdateRepoIndexer

func UpdateRepoIndexer(repo *models.Repository, watchers ...chan<- error)

UpdateRepoIndexer update a repository's entries in the indexer

Types

type BleveIndexer

type BleveIndexer struct {
	// contains filtered or unexported fields
}

BleveIndexer represents a bleve indexer implementation

func NewBleveIndexer

func NewBleveIndexer(indexDir string) (*BleveIndexer, bool, error)

NewBleveIndexer creates a new bleve local indexer

func (*BleveIndexer) Close

func (b *BleveIndexer) Close()

Close close the indexer

func (*BleveIndexer) Delete

func (b *BleveIndexer) Delete(repoID int64) error

Delete deletes indexes by ids

func (*BleveIndexer) Index

func (b *BleveIndexer) Index(repoID int64) error

Index indexes the data

func (*BleveIndexer) Search

func (b *BleveIndexer) Search(repoIDs []int64, keyword string, page, pageSize int) (int64, []*SearchResult, error)

Search searches for files in the specified repo. Returns the matching file-paths

type Indexer

type Indexer interface {
	Index(repoID int64) error
	Delete(repoID int64) error
	Search(repoIDs []int64, keyword string, page, pageSize int) (int64, []*SearchResult, error)
	Close()
}

Indexer defines an interface to indexer issues contents

type RepoIndexerData

type RepoIndexerData struct {
	RepoID  int64
	Content string
}

RepoIndexerData data stored in the repo indexer

func (*RepoIndexerData) Type

func (d *RepoIndexerData) Type() string

Type returns the document type, for bleve's mapping.Classifier interface.

type Result

type Result struct {
	RepoID         int64
	Filename       string
	HighlightClass string
	LineNumbers    []int
	FormattedLines gotemplate.HTML
}

Result a search result to display

func PerformSearch

func PerformSearch(repoIDs []int64, keyword string, page, pageSize int) (int, []*Result, error)

PerformSearch perform a search on a repository

type SearchResult

type SearchResult struct {
	RepoID     int64
	StartIndex int
	EndIndex   int
	Filename   string
	Content    string
}

SearchResult result of performing a search in a repo

Jump to

Keyboard shortcuts

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