facet

package
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: 9 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

View Source
const (
	SortByCount = `count`
	SortByAlpha = `alpha`
)

Variables

This section is empty.

Functions

func Filter

func Filter(bits *roaring.Bitmap, fields []*Facet, filters []any) (*roaring.Bitmap, error)

func FilteredItems

func FilteredItems(data []map[string]any, ids []any) []map[string]any

FilteredItems returns the subset of data.

func ItemsByBitmap

func ItemsByBitmap(data []map[string]any, bits *roaring.Bitmap) []map[string]any

func SortByAlphaFunc

func SortByAlphaFunc(a *Item, b *Item) int

func SortByCountFunc

func SortByCountFunc(a *Item, b *Item) int

Types

type Facet added in v0.0.24

type Facet struct {
	Attribute string  `json:"attribute"`
	Items     []*Item `json:"items"`
	Count     int     `json:"count"`
	Sep       string  `json:"-"`

	SortBy string `json:"-"`
	Order  string `json:"-"`
	// contains filtered or unexported fields
}

func NewFacet added in v0.0.24

func NewFacet(attr string) *Facet

func NewFacets

func NewFacets(attrs []string) []*Facet

func (*Facet) Add added in v0.0.24

func (f *Facet) Add(val any, ids []int)

func (*Facet) Filter added in v0.0.24

func (f *Facet) Filter(val string) *roaring.Bitmap

func (*Facet) Find added in v0.0.24

func (f *Facet) Find(val any) []*Item

func (*Facet) FindByIndex added in v0.0.24

func (f *Facet) FindByIndex(ti ...int) []*Item

func (*Facet) FindByLabel added in v0.0.24

func (f *Facet) FindByLabel(label string) *Item

func (*Facet) FindByValue added in v0.0.24

func (f *Facet) FindByValue(val string) *Item

func (*Facet) Fuzzy added in v0.0.24

func (f *Facet) Fuzzy(term string) *roaring.Bitmap

func (*Facet) GetValues added in v0.0.24

func (f *Facet) GetValues() []string

func (*Facet) Keywords added in v0.0.24

func (f *Facet) Keywords() []*Item

func (*Facet) Len added in v0.0.24

func (f *Facet) Len() int

Len returns the number of items, to satisfy the fuzzy.Source interface.

func (*Facet) Search added in v0.0.24

func (f *Facet) Search(term string) []*Item

func (*Facet) SortTokens added in v0.0.24

func (f *Facet) SortTokens() []*Item

func (*Facet) String added in v0.0.24

func (f *Facet) String(i int) string

String returns an Item.Value, to satisfy the fuzzy.Source interface.

func (*Facet) Tokenize added in v0.0.24

func (f *Facet) Tokenize(val any) []*Item

type Fields added in v0.0.24

type Fields struct {
	Facets []*Facet `json:"facetFields"`
	// contains filtered or unexported fields
}

func New

func New(data []map[string]any, param *param.Params) (*Fields, error)

func NewFields

func NewFields(fields []string) *Fields

func (*Fields) Bitmap added in v0.0.24

func (f *Fields) Bitmap() *roaring.Bitmap

func (*Fields) Calculate added in v0.0.24

func (f *Fields) Calculate() *Fields

func (*Fields) Filter added in v0.0.24

func (f *Fields) Filter(filters []any) (*Fields, error)

func (Fields) GetFacet added in v0.0.24

func (f Fields) GetFacet(attr string) (*Facet, error)

func (*Fields) Items added in v0.0.24

func (f *Fields) Items() []string

func (Fields) Len added in v0.0.24

func (f Fields) Len() int

func (*Fields) MarshalJSON added in v0.0.24

func (f *Fields) MarshalJSON() ([]byte, error)

type Item added in v0.0.24

type Item struct {
	Value     string `json:"value"`
	Label     string `json:"label"`
	Count     int    `json:"count"`
	RelatedTo []int  `json:"relatedTo"`
	Children  *Facet `json:"-"`
	// contains filtered or unexported fields
}

func KeywordTokenizer

func KeywordTokenizer(val any) []*Item

func NewItem added in v0.0.24

func NewItem(label string) *Item

func SortTokensByAlpha

func SortTokensByAlpha(items []*Item) []*Item

func SortTokensByCount

func SortTokensByCount(items []*Item) []*Item

func (*Item) Add added in v0.0.24

func (i *Item) Add(ids ...int)

func (*Item) Bitmap added in v0.0.24

func (i *Item) Bitmap() *roaring.Bitmap

func (*Item) Contains added in v0.0.24

func (i *Item) Contains(id int) bool

func (*Item) GetItems added in v0.0.24

func (i *Item) GetItems() []int

func (*Item) Len added in v0.0.24

func (i *Item) Len() int

func (*Item) SetValue added in v0.0.24

func (i *Item) SetValue(txt string) *Item

Jump to

Keyboard shortcuts

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