search

package
v0.0.0-...-a139185 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package search contains types for searching for terms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Searcher

type Searcher interface {
	Search(input string, limit int, ignore []string) (terms []*Term, err error)
	SearchCat(input string, cat, limit int, ignore []string) (terms []*Term, err error)

	// Return terms starting with the input
	Autocomplete(input string) (terms []string, err error)

	// Synchronize all terms with the search store
	SyncTerms(terms []*Term) (err error)
	// Synchronize a single term after updates
	SyncTerm(term *Term) (err error)
	// Delete a term from the search store
	SyncDelete(id int) (err error)
}

Searcher is an interface for searching the term database.

type Term

type Term struct {
	ID              int       `json:"id"`
	Category        int       `json:"category_id"`
	CategoryName    string    `json:"category"`
	Name            string    `json:"name"`
	Aliases         []string  `json:"aliases"`
	Description     string    `json:"description"`
	Note            string    `json:"note,omitempty"`
	Source          string    `json:"source"`
	Created         time.Time `json:"created"`
	LastModified    time.Time `json:"last_modified"`
	Tags            []string  `json:"-"`
	DisplayTags     []string  `json:"tags,omitempty"`
	ContentWarnings string    `json:"content_warnings,omitempty"`
	ImageURL        string    `json:"image_url,omitempty"`

	Flags TermFlag `json:"flags"`

	// Rank is only populated with db.Search()
	Rank float64 `json:"rank"`
	// Headline is only populated with db.Search()
	Headline string `json:"headline,omitempty"`
}

Term holds info on a single term

func (*Term) Disputed

func (t *Term) Disputed() bool

Disputed returns true if the term is disputed

func (*Term) RandomHidden

func (t *Term) RandomHidden() bool

RandomHidden returns true if the term is hidden from the random command

func (*Term) SearchHidden

func (t *Term) SearchHidden() bool

SearchHidden returns true if the term is hidden from search results

func (*Term) Warning

func (t *Term) Warning() bool

Warning returns true if the term has a warning on its term card

type TermFlag

type TermFlag int

TermFlag ...

const (
	FlagSearchHidden TermFlag = 1 << iota
	FlagRandomHidden
	FlagShowWarning
	FlagListHidden
	FlagDisputed
)

Constants for term flags

Directories

Path Synopsis
Package pg implements the search.Searcher interface with the existing PostgreSQL database.
Package pg implements the search.Searcher interface with the existing PostgreSQL database.
Package typesense implements search methods with a Typesense search server.
Package typesense implements search methods with a Typesense search server.

Jump to

Keyboard shortcuts

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