search

package
v0.9.15 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewService

func NewService(
	ctx context.Context,
	validation *validator.Validate,
	storage *searchdb.Storage,
	indexPath string,
	cache *redis.Storage,
	log *zerolog.Logger,
) mo.Result[*Service]

Types

type Indexer

type Indexer interface {
	CreateIndex(path string) error
}

type Options

type Options struct {
	// Query is the search query used for a text search.
	Query string `json:"query" query:"q" default:""`

	// Sort is the field, that should be sorted by.
	// When left empty, the default sorting is used.
	Sort string `json:"sort,omitempty" query:"sort,omitempty" validate:"oneof=score added modified name"`

	// LocalFirst determines whether the results from the current instance should be
	// preferred over remote results.
	LocalFirst bool `json:"localFirst,omitempty" query:"local_first" default:"true"`

	// SortDescending defines the sort order.
	SortDescending bool `json:"SortDescending" query:"desc" default:"true"`

	// Fuzzy defines whether to use fuzzy or wildcard search.
	Fuzzy bool `json:"fuzzy,omitempty" query:"fuzzy" default:"false"`

	// Page is current page.
	Page uint `json:"page" query:"page" default:"0"`

	// PageSize defines the number of hits returned per page.
	//
	// PageSize is infinite when set to 0 (i.e. infinite scroll).
	PageSize uint `json:"pageSize" query:"pageSize" default:"10" validate:"gte=0,lte=180"`

	// Categories are the categories to search in. By default,
	// a Union category is performed to search in all categories.
	Categories []target.Category `json:"categories" query:"category" validate:"unique,dive" default:"union"`
}

Options defines a set of optional search parameters.

type Service

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

func ServiceNoIndex added in v0.9.15

func ServiceNoIndex(
	validation *validator.Validate,
	storage *searchdb.Storage,
	cache *redis.Storage,
	log *zerolog.Logger,
) *Service

func (*Service) CreateIndex added in v0.9.15

func (s *Service) CreateIndex(
	ctx context.Context,
	runtimeStats bool,
	path string,
) error

func (*Service) RunQuery

func (s *Service) RunQuery(ctx context.Context, opts *Options) (res *bleve.SearchResult, err error)

RunQuery performs a search on the bleve index

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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