search

package
v2.16.11+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: Apache-2.0 Imports: 7 Imported by: 275

Documentation

Overview

Package search provides client-side repository searching.

This supports building an in-memory search index based on the contents of multiple repositories, and then using string matching or regular expressions to find matches.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortScore

func SortScore(r []*Result)

SortScore does an in-place sort of the results.

Lowest scores are highest on the list. Matching scores are subsorted alphabetically.

Types

type Index

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

Index is a searchable index of chart information.

func NewIndex

func NewIndex() *Index

NewIndex creates a new Index.

func (*Index) AddRepo

func (i *Index) AddRepo(rname string, ind *repo.IndexFile, all bool)

AddRepo adds a repository index to the search index.

func (*Index) All

func (i *Index) All() []*Result

All returns all charts in the index as if they were search results.

Each will be given a score of 0.

func (*Index) Chart

func (i *Index) Chart(name string) (*repo.ChartVersion, error)

Chart returns the ChartVersion for a particular name.

func (*Index) Search

func (i *Index) Search(term string, threshold int, regexp bool) ([]*Result, error)

Search searches an index for the given term.

Threshold indicates the maximum score a term may have before being marked irrelevant. (Low score means higher relevance. Golf, not bowling.)

If regexp is true, the term is treated as a regular expression. Otherwise, term is treated as a literal string.

func (*Index) SearchLiteral

func (i *Index) SearchLiteral(term string, threshold int) []*Result

SearchLiteral does a literal string search (no regexp).

func (*Index) SearchRegexp

func (i *Index) SearchRegexp(re string, threshold int) ([]*Result, error)

SearchRegexp searches using a regular expression.

type Result

type Result struct {
	Name  string
	Score int
	Chart *repo.ChartVersion
}

Result is a search result.

Score indicates how close it is to match. The higher the score, the longer the distance.

Jump to

Keyboard shortcuts

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