search

package module
v0.0.0-...-ad90ba7 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 14 Imported by: 0

README

go-bluge-hl

Go Reference

Package search provides a simple high level wrapper for bluge search, written in Go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fuzzy

func Fuzzy(input string, max int) *bluge.TopNSearch

func Normalize

func Normalize(text []byte) []byte

Normalize removes diacritics, transforms to lower case and replaces all non-alphanumeric bytes with spaces.

It is used internally and can be used on input queries which don't have an analyzer (= all except bluge.MatchQuery and bluge.MatchPhraseQuery).

func Prefix

func Prefix(input string, max int) *bluge.TopNSearch

Types

type Pool

type Pool[T any] struct {
	// contains filtered or unexported fields
}

A pool contains the documents and the search index reader.

func MakePool

func MakePool[T any](documents []T, fields map[string]func(T) string) (*Pool[T], error)

func (*Pool[T]) Close

func (pool *Pool[T]) Close() error

func (*Pool[T]) Search

func (pool *Pool[T]) Search(request *bluge.TopNSearch) ([]Result[T], error)

type Result

type Result[T any] struct {
	Document   T                        `json:"document"`
	Highlights map[string]template.HTML `json:"highlights"` // key: field name, value: full content or fragment
}

Jump to

Keyboard shortcuts

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