search

package
v3.1.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2017 License: MIT Imports: 15 Imported by: 2

Documentation

Overview

Package search provides search interface and functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(c conf.Config)

Init initializes the search

func ParseGoto added in v1.5.1

func ParseGoto(gt string) int

ParseGoto parses goto from a given string

func ParseLimit added in v1.9.0

func ParseLimit(limit string) int

ParseLimit parses limit from a given string

func ParsePage added in v1.5.1

func ParsePage(page string) int

ParsePage parses page from a given string

func ParseTimeout added in v1.5.1

func ParseTimeout(timeout string) time.Duration

ParseTimeout parses timeout from a given string

func ProviderRegister

func ProviderRegister(provider interface{}) error

ProviderRegister registers a search provider

func Providers

func Providers() []string

Providers returns a sorted list of the names of the providers

Types

type Provider added in v1.8.0

type Provider struct {
	Name     string
	Title    string
	Enabled  bool
	Noui     bool
	Priority int64
	Rewrite  string
	Searcher
}

Provider represents a provider

func ProviderByName added in v1.8.0

func ProviderByName(name string) (Provider, error)

ProviderByName returns a provider by the given name

type Query added in v1.5.0

type Query struct {
	Provider   string
	Keyword    string
	Limit      int
	Page       int
	Goto       int
	Timeout    time.Duration
	Start      time.Time
	Elapsed    time.Duration
	HTTPStatus int
	Results    Results
}

Query represents a search query

func (*Query) Do

func (query *Query) Do() error

Do runs the search query

func (*Query) DoPrint

func (query *Query) DoPrint(err error)

DoPrint handles terminal output for Do function

type Result added in v1.4.0

type Result struct {
	Link        string    `json:"link"`
	Title       string    `json:"title"`
	Description string    `json:"description"`
	Date        time.Time `json:"date"`
	From        string    `json:"from"`
}

Result represents a search result

type Results added in v1.4.0

type Results []Result

Results represents a list of search results

func (Results) Len added in v1.4.0

func (r Results) Len() int

Sort implementation

func (Results) Less added in v1.4.0

func (r Results) Less(i, j int) bool

func (Results) Swap added in v1.4.0

func (r Results) Swap(i, j int)

type Searcher

type Searcher interface {
	// Search makes a search
	Search(ctx context.Context, args map[string]interface{}) ([]map[string]interface{}, error)
}

Searcher is the interface that must be implemented by a search provider

Jump to

Keyboard shortcuts

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