search

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ElasticSearch
	OpenSearch
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action func(client *es.Client) (*esapi.Response, error)

type BoolQuery

type BoolQuery struct {
	Bool map[string]interface{} `json:"bool"`
}

type Configurator

type Configurator interface {
	Addresses() []string
	SearchEngine() int
}

type Doc

type Doc map[types.ColumnName]interface{}

func NewDoc

func NewDoc(id string) *Doc

func (*Doc) Del

func (d *Doc) Del(key types.ColumnName) (any, error)

func (*Doc) GetId

func (d *Doc) GetId() *string

func (*Doc) Set

func (d *Doc) Set(key types.ColumnName, value any, builtins maps.Set[types.ColumnName]) national.Sentence

func (*Doc) SetId

func (d *Doc) SetId(id string) national.Sentence

func (*Doc) SetNX

func (d *Doc) SetNX(key types.ColumnName, value any)

type FunctionScore

type FunctionScore struct {
	Query     BoolQuery        `json:"query"`
	Functions []FunctionSyntax `json:"functions"`
	BoostMode string           `json:"boost_mode"`
	MinScore  float64          `json:"min_score"`
}

type FunctionScoreQuery

type FunctionScoreQuery struct {
	FunctionScore FunctionScore `json:"function_score"`
}

type FunctionSyntax

type FunctionSyntax struct {
	ScriptScore ScriptScore `json:"script_score"`
}

type Hit

type Hit[T interface{}, R interface{}] struct {
	Index  string  `json:"_index"`
	Id     string  `json:"_id"`
	Score  float64 `json:"_score"`
	Source T       `json:"_source"`
	Sort   *R      `json:"sort"`
}

type Hits

type Hits[T interface{}, R interface{}] struct {
	Total Total       `json:"total"`
	Hits  []Hit[T, R] `json:"hits"`
}

type Query

type Query[R interface{}] struct {
	Size   int64              `json:"size,omitempty"`
	Query  FunctionScoreQuery `json:"query,omitempty"`
	Source []string           `json:"_source,omitempty"`
	Sort   []any              `json:"sort,omitempty"`
	After  *R                 `json:"search_after,omitempty"`
}

type Records

type Records[T, R interface{}] struct {
	Hits Hits[T, R] `json:"hits"`
}

func (*Records[T, R]) Last

func (r *Records[T, R]) Last() *R

type Result

type Result struct {
	Shards  Shards `yaml:"_shards,omitempty"`
	Index   string `yaml:"_index,omitempty"`
	Id      string `yaml:"_id,omitempty"`
	Version int    `yaml:"_version,omitempty"`
	Seq     int    `yaml:"_seq_no,omitempty"`
	Primary int    `yaml:"_primary_term,omitempty"`
	Result  string `yaml:"result"`
}

func (*Result) GetId

func (r *Result) GetId() string

type Script

type Script struct {
	ID     string         `json:"id,omitempty"`
	Source string         `json:"source,omitempty"`
	Params map[string]any `json:"params"`
	Lang   string         `json:"lang,omitempty"`
}

type ScriptScore

type ScriptScore struct {
	Script Script `json:"script"`
}

type Searcher

type Searcher interface {
	SearchRaw(ctxt context.Context, index string, query any, result any) error
	Create(ctxt context.Context, index string, doc *Doc, result *Result) (error, Warn)
	Update(ctxt context.Context, index string, doc *Doc, result *Result) (error, Warn)
	Delete(ctxt context.Context, index string, doc *Doc, result *Result) (error, Warn)
	BulkDelete(ctxt context.Context, index string, ids []*string, result *Result) (error, Warn)
	CreateIndex(ctxt context.Context, index string, schema string, result *Result) (error, Warn)
}

func New

func New(c Configurator) Searcher

func NewElasticSearchClient

func NewElasticSearchClient(configurator Configurator) Searcher

type Shards

type Shards struct {
	Total      int `yaml:"total,omitempty"`
	Failed     int `yaml:"failed,omitempty"`
	Successful int `yaml:"successful,omitempty"`
}

type Total

type Total struct {
	Value    int    `json:"value"`
	Relation string `json:"relation"`
}

type TypedSearcher

type TypedSearcher[T interface{}, R interface{}] interface {
	Search(ctxt context.Context, index string, query any) (*Records[T, R], error)
	SearchFunction(context.Context, string, *string, *map[string]interface{}, *map[string]interface{}, []string, []any) (*Records[T, R], error)
	SearchFunctionContinuous(context.Context, string, *string, *map[string]interface{}, *map[string]interface{}, []string, []any, *Records[T, R]) (*Records[T, R], error)
	ContinuousSearchByFunctionWithScriptID(ctxt context.Context, index string, scrollSize int64, source []string, sorts []any, scriptId *string, cond *map[string]interface{}, params *map[string]interface{}, result *Records[T, R]) (*Records[T, R], error)
}

func NewTypedSearcher

func NewTypedSearcher[T, R interface{}](searcher Searcher) TypedSearcher[T, R]

type UpdateDocument

type UpdateDocument struct {
	Doc Doc `json:"doc"`
}

type Warn

type Warn *string

func Warning

func Warning(message string) Warn

Jump to

Keyboard shortcuts

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