code

package
v1.17.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: MIT Imports: 41 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 Init

func Init()

Init initialize the repo indexer

func IsAvailable added in v1.17.0

func IsAvailable() bool

IsAvailable checks if issue indexer is available

func PerformSearch

func PerformSearch(ctx context.Context, repoIDs []int64, language, keyword string, page, pageSize int, isMatch bool) (int, []*Result, []*SearchResultLanguages, error)

PerformSearch perform a search on a repository

func UpdateRepoIndexer

func UpdateRepoIndexer(repo *repo_model.Repository)

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(ctx context.Context, repo *repo_model.Repository, sha string, changes *repoChanges) error

Index indexes the data

func (*BleveIndexer) Ping added in v1.17.0

func (b *BleveIndexer) Ping() bool

Ping does nothing

func (*BleveIndexer) Search

func (b *BleveIndexer) Search(ctx context.Context, repoIDs []int64, language, keyword string, page, pageSize int, isMatch bool) (int64, []*SearchResult, []*SearchResultLanguages, error)

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

func (*BleveIndexer) SetAvailabilityChangeCallback added in v1.17.0

func (b *BleveIndexer) SetAvailabilityChangeCallback(callback func(bool))

SetAvailabilityChangeCallback does nothing

type ElasticSearchIndexer added in v1.13.0

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

ElasticSearchIndexer implements Indexer interface

func NewElasticSearchIndexer added in v1.13.0

func NewElasticSearchIndexer(url, indexerName string) (*ElasticSearchIndexer, bool, error)

NewElasticSearchIndexer creates a new elasticsearch indexer

func (*ElasticSearchIndexer) Close added in v1.13.0

func (b *ElasticSearchIndexer) Close()

Close implements indexer

func (*ElasticSearchIndexer) Delete added in v1.13.0

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

Delete deletes indexes by ids

func (*ElasticSearchIndexer) Index added in v1.13.0

func (b *ElasticSearchIndexer) Index(ctx context.Context, repo *repo_model.Repository, sha string, changes *repoChanges) error

Index will save the index data

func (*ElasticSearchIndexer) Ping added in v1.17.0

func (b *ElasticSearchIndexer) Ping() bool

Ping checks if elastic is available

func (*ElasticSearchIndexer) Search added in v1.13.0

func (b *ElasticSearchIndexer) Search(ctx context.Context, repoIDs []int64, language, keyword string, page, pageSize int, isMatch bool) (int64, []*SearchResult, []*SearchResultLanguages, error)

Search searches for codes and language stats by given conditions.

func (*ElasticSearchIndexer) SetAvailabilityChangeCallback added in v1.17.0

func (b *ElasticSearchIndexer) SetAvailabilityChangeCallback(callback func(bool))

SetAvailabilityChangeCallback sets callback that will be triggered when availability changes

type Indexer

type Indexer interface {
	Ping() bool
	SetAvailabilityChangeCallback(callback func(bool))
	Index(ctx context.Context, repo *repo_model.Repository, sha string, changes *repoChanges) error
	Delete(repoID int64) error
	Search(ctx context.Context, repoIDs []int64, language, keyword string, page, pageSize int, isMatch bool) (int64, []*SearchResult, []*SearchResultLanguages, error)
	Close()
}

Indexer defines an interface to index and search code contents

type IndexerData added in v1.13.0

type IndexerData struct {
	RepoID int64
}

IndexerData represents data stored in the code indexer

type RepoIndexerData

type RepoIndexerData struct {
	RepoID    int64
	CommitID  string
	Content   string
	Language  string
	UpdatedAt time.Time
}

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
	CommitID       string
	UpdatedUnix    timeutil.TimeStamp
	Language       string
	Color          string
	LineNumbers    []int
	FormattedLines string
}

Result a search result to display

type SearchResult

type SearchResult struct {
	RepoID      int64
	StartIndex  int
	EndIndex    int
	Filename    string
	Content     string
	CommitID    string
	UpdatedUnix timeutil.TimeStamp
	Language    string
	Color       string
}

SearchResult result of performing a search in a repo

type SearchResultLanguages added in v1.12.0

type SearchResultLanguages struct {
	Language string
	Color    string
	Count    int
}

SearchResultLanguages result of top languages count in search results

Jump to

Keyboard shortcuts

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