srch

package module
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 24 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoDataErr = errors.New("no data")

Functions

func ByteSrc

func ByteSrc(d []byte) ([]map[string]any, error)

StringSrc parses raw json formatted data.

func DecodeData

func DecodeData(r io.Reader, ct string, data *[]map[string]any) error

func DecodeDataO added in v0.0.20

func DecodeDataO(r io.Reader) ([]map[string]any, error)

DecodeDataO decodes data from a io.Reader.

func DecodeJSON added in v0.0.20

func DecodeJSON(r io.Reader, data *[]map[string]any) error

func DecodeNDJSON added in v0.0.20

func DecodeNDJSON(r io.Reader, data *[]map[string]any) error

DecodeNDJSON decodes data from a io.Reader.

func DirSrc

func DirSrc(dir string) ([]map[string]any, error)

DirSrc parses json files from a directory.

func FileSrc

func FileSrc(files ...string) ([]map[string]any, error)

FileSrc takes json data files.

func FilterDataByAttr added in v0.0.20

func FilterDataByAttr(hits []map[string]any, fields []string) []map[string]any

func FilterDataByID added in v0.0.20

func FilterDataByID(hits []map[string]any, uids []any, uid string) []map[string]any

func GetData added in v0.0.20

func GetData(data *[]map[string]any, paths ...string) error

func GetFSData added in v0.0.20

func GetFSData(data *[]map[string]any, paths ...string) error

func ParseSort added in v0.0.30

func ParseSort(attr string) (string, string)

func ReaderSrc

func ReaderSrc(r io.Reader) ([]map[string]any, error)

ReaderSrc takes an io.Reader of a json stream.

func StringSliceSrc

func StringSliceSrc(data []string) []map[string]any

StringSliceSrc takes a string slice and returns data for for indexing with the default field of 'title'.

func StringSrc

func StringSrc(d string) ([]map[string]any, error)

StringSrc parses index data from a json formatted string.

Types

type Index

type Index struct {
	Indexer
	*data.Data

	Docs []map[string]any

	Params *param.Params
	// contains filtered or unexported fields
}

Index is a structure for facets and data.

func New

func New(settings string) (*Index, error)

func (*Index) FilterDataBySrchAttr added in v0.0.20

func (idx *Index) FilterDataBySrchAttr() []map[string]any

func (*Index) GetData

func (idx *Index) GetData() error

func (*Index) Search

func (idx *Index) Search(params string) (*Response, error)

type Indexer added in v0.0.20

type Indexer interface {
	Index(uid string, data map[string]any) error
	Batch(data []map[string]any) error
	Len() int
	Searcher
}

type Request added in v0.0.20

type Request struct {
	*param.Params
	// contains filtered or unexported fields
}

func GetViperParams added in v0.0.21

func GetViperParams() *Request

func NewRequest added in v0.0.20

func NewRequest() *Request

func ParseRequest added in v0.0.20

func ParseRequest(params string) (*Request, error)

func (*Request) AndFilter added in v0.0.20

func (r *Request) AndFilter(filters ...string) *Request

func (*Request) DefaultField added in v0.0.20

func (r *Request) DefaultField(val string) *Request

func (*Request) FacetAttr added in v0.0.20

func (r *Request) FacetAttr(attr ...string) *Request

func (*Request) FacetFilters added in v0.0.20

func (r *Request) FacetFilters(filters ...any) *Request

func (*Request) Facets added in v0.0.20

func (r *Request) Facets(attr ...string) *Request

func (*Request) Filters added in v0.0.20

func (r *Request) Filters(val string) *Request

func (*Request) Format added in v0.0.21

func (r *Request) Format(val string) *Request

func (*Request) HitsPerPage added in v0.0.20

func (r *Request) HitsPerPage(p int) *Request

func (*Request) OrFilter added in v0.0.20

func (r *Request) OrFilter(filters ...string) *Request

func (*Request) Order added in v0.0.20

func (r *Request) Order(val string) *Request

func (*Request) Page added in v0.0.20

func (r *Request) Page(p int) *Request

func (*Request) Parse added in v0.0.20

func (r *Request) Parse(params string) (*Request, error)

func (*Request) Query added in v0.0.20

func (r *Request) Query(val string) *Request

func (*Request) RtrvAttr added in v0.0.21

func (r *Request) RtrvAttr(attr ...string) *Request

func (*Request) SetPath added in v0.0.22

func (p *Request) SetPath(path string) *Request

func (*Request) SetRoute added in v0.0.20

func (p *Request) SetRoute(path string) *Request

func (*Request) SetValues added in v0.0.20

func (r *Request) SetValues(vals url.Values) *Request

func (*Request) SortAttr added in v0.0.20

func (r *Request) SortAttr(attr ...string) *Request

func (*Request) SortBy added in v0.0.20

func (r *Request) SortBy(val string) *Request

func (*Request) SortFacetsBy added in v0.0.20

func (r *Request) SortFacetsBy(val string) *Request

func (*Request) SrchAttr added in v0.0.20

func (r *Request) SrchAttr(attr ...string) *Request

func (*Request) UID added in v0.0.20

func (r *Request) UID(val string) *Request

type Response

type Response struct {
	*param.Params

	RawQuery    string           `json:"params"`
	FacetFields []*facet.Facet   `json:"facetFields"`
	Facets      *facet.Fields    `json:"facets"`
	Hits        []map[string]any `json:"hits"`
	NbHits      int              `json:"nbHits"`
	NbPages     int              `json:"nbPages"`
	// contains filtered or unexported fields
}

func NewResponse

func NewResponse(hits []map[string]any, params *param.Params) (*Response, error)

func (*Response) FilterByFacetValue added in v0.0.25

func (res *Response) FilterByFacetValue(attr, val string) []map[string]any

func (*Response) FilterResults added in v0.0.20

func (res *Response) FilterResults() []map[string]any

func (*Response) Header added in v0.0.20

func (res *Response) Header() http.Header

type Searcher added in v0.0.20

type Searcher interface {
	Search(query string) ([]map[string]any, error)
}

type Sort added in v0.0.30

type Sort struct {
	Field string
	Type  string
}

func NewSort added in v0.0.30

func NewSort(val string) *Sort

func (*Sort) Sort added in v0.0.30

func (s *Sort) Sort(data []map[string]any) []map[string]any

func (*Sort) SortByInt added in v0.0.30

func (s *Sort) SortByInt(data []map[string]any)

func (*Sort) SortByStr added in v0.0.30

func (s *Sort) SortByStr(data []map[string]any)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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