gsearch

package
v0.0.0-...-bc4c757 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultGemHighlightAfter = "]]"
View Source
const DefaultGemHighlightBefore = "[["
View Source
const PageSize = 15

Variables

This section is empty.

Functions

func IndexDb

func IndexDb(ctx context.Context, index bleve.Index, cfg *config.Config) (err error)

func IndexImages

func IndexImages(ctx context.Context, index bleve.Index, cfg *config.Config) (err error)

func IndexPages

func IndexPages(ctx context.Context, index bleve.Index, cfg *config.Config) (err error)

func NewIndex

func NewIndex(path string, name string) (idx bleve.Index, err error)

func OpenIndex

func OpenIndex(path string, name string) (idx bleve.Index, err error)

Types

type FragmentFormatter

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

func NewFragmentFormatter

func NewFragmentFormatter(before, after string) *FragmentFormatter

func (*FragmentFormatter) Format

func (a *FragmentFormatter) Format(f *highlight.Fragment, orderedTermLocations highlight.TermLocations) string

type ImageDoc

type ImageDoc struct {
	AltText   string
	Image     string
	SourceUrl string
	FetchTime time.Time
}

type ImageSearchRequest

type ImageSearchRequest struct {
	// this should be set to "searchimg"
	Type string `json:"t"`

	Query          string `json:"q"`
	Page           int    `json:"page,omitempty"`
	HighlightStyle string `json:"-"`
}

type ImageSearchResponse

type ImageSearchResponse struct {
	TotalResults uint64              `json:"n"`
	Results      []ImageSearchResult `json:"results"`
	Duration     time.Duration       `json:"duration"`

	// used by the search daemon and cgi
	Err string `json:"err,omitempty"`
}

func SearchImages

func SearchImages(req ImageSearchRequest, idx bleve.Index) (resp ImageSearchResponse, err error)

type ImageSearchResult

type ImageSearchResult struct {
	ImageHash string    `json:"image_id"`
	Image     string    `json:"image"`
	AltText   string    `json:"alt"`
	SourceUrl string    `json:"url"`
	FetchTime time.Time `json:"fetch_time"`
	Relevance float64   `json:"score"`
}

type PageDoc

type PageDoc struct {
	Title       string
	Content     string
	Lang        string
	Links       string
	PageRank    float64
	HostRank    float64
	Kind        string
	ContentType string
	ContentSize uint64
}

type PageSearchRequest

type PageSearchRequest struct {
	// this should be set to "search"
	Type string `json:"t"`

	Query          string `json:"q"`
	Page           int    `json:"page,omitempty"`
	HighlightStyle string `json:"-"`
	Verbose        bool   `json:"-"`
}

type PageSearchResponse

type PageSearchResponse struct {
	TotalResults uint64             `json:"n"`
	Results      []PageSearchResult `json:"results"`
	Duration     time.Duration      `json:"duration"`

	// used by the search daemon and cgi
	Err string `json:"err,omitempty"`
}

func SearchPages

func SearchPages(req PageSearchRequest, idx bleve.Index) (resp PageSearchResponse, err error)

type PageSearchResult

type PageSearchResult struct {
	Url         string  `json:"url"`
	Title       string  `json:"title"`
	Snippet     string  `json:"snippet"`
	UrlRank     float64 `json:"prank"`
	HostRank    float64 `json:"hrank"`
	Relevance   float64 `json:"score"`
	ContentType string  `json:"content_type"`
	ContentSize uint64  `json:"content_size"`

	// used by templates; this is _not_ set by the Search function.
	Hostname string `json:"-"`
}

type RankedSort

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

func (*RankedSort) Copy

func (so *RankedSort) Copy() search.SearchSort

func (*RankedSort) Descending

func (so *RankedSort) Descending() bool

func (*RankedSort) RequiresDocID

func (so *RankedSort) RequiresDocID() bool

func (*RankedSort) RequiresFields

func (so *RankedSort) RequiresFields() []string

func (*RankedSort) RequiresScoring

func (so *RankedSort) RequiresScoring() bool

func (*RankedSort) Reverse

func (so *RankedSort) Reverse()

func (*RankedSort) UpdateVisitor

func (so *RankedSort) UpdateVisitor(field string, term []byte)

func (*RankedSort) Value

func (so *RankedSort) Value(a *search.DocumentMatch) string

Jump to

Keyboard shortcuts

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