es

package
v0.0.0-...-adb56df Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBulkClient

func NewBulkClient() esutil.BulkIndexer

Types

type Hit

type Hit struct {
	Total struct {
		Value    int64  `json:"value"`
		Relation string `json:"relation"`
	} `json:"total"`
	MaxScore float64    `json:"max_score"`
	Hits     []*HitItem `json:"hits"`
}

type HitItem

type HitItem struct {
	Index  string           `json:"_index"`
	Type   string           `json:"_type"`
	ID     string           `json:"_id"`
	Score  float64          `json:"_score"`
	Source map[string]any   `json:"_source"`
	Fields map[string][]any `json:"fields"`
}

type IndexBody

type IndexBody interface {
	ID() string
	BodyReader() (io.Reader, error)
}

type Mapping

type Mapping interface {
	BodyReader() (io.Reader, error)
}
type Search interface {
	CreateIndex(index string, mapping Mapping) error
	Index(index string, body IndexBody) error
	Search(index string, body *SearchRequestBody) (*SearchResponse, error)
}

func NewSearch

func NewSearch(addresses []string, userName, password, fingerPrint string) Search

func NewSearchWithConfig

func NewSearchWithConfig(config elasticsearch.Config) Search

type SearchRequestBody

type SearchRequestBody struct {
	DocValueFields   any                `json:"docvalue_fields,omitempty"`
	Fields           any                `json:"fields,omitempty"`
	StoredFields     any                `json:"stored_fields,omitempty"`
	Explain          *bool              `json:"explain,omitempty"`
	From             int64              `json:"from"`
	IndicesBoost     map[string]float64 `json:"indices_boost,omitempty"`
	KNN              any                `json:"knn,omitempty"`
	MinScore         *float64           `json:"min_score,omitempty"`
	Pin              any                `json:"pin,omitempty"`
	Query            map[string]any     `json:"query,omitempty"`
	RuntimeMappings  any                `json:"runtime_mappings,omitempty"`
	SeqNoPrimaryTerm *bool              `json:"seq_no_primary_term,omitempty"`
	Size             *int64             `json:"size,omitempty"`
	Sort             map[string]any     `json:"sort,omitempty"`
	Source           any                `json:"_source,omitempty"`
	TerminateAfter   *int64             `json:"terminate_after,omitempty"`
	Timeout          *int64             `json:"timeout,omitempty"`
	Version          *bool              `json:"version,omitempty"`
	Aggs             map[string]any     `json:"aggs,omitempty"`
}

func (*SearchRequestBody) BodyReader

func (r *SearchRequestBody) BodyReader() (io.Reader, error)

type SearchResponse

type SearchResponse struct {
	Took     int64 `json:"took"`
	TimedOut bool  `json:"timed_out"`
	Shards   struct {
		Total      int64 `json:"total"`
		Successful int64 `json:"successful"`
		Skipped    int64 `json:"skipped"`
		Failed     int64 `json:"failed"`
	} `json:"_shards"`
	Hits         Hit `json:"hits"`
	Aggregations map[string]struct {
		Buckets []struct {
			KeyAsString string `json:"key_as_string"`
			Key         int64  `json:"key"`
			DocCount    int64  `json:"doc_count"`
		} `json:"buckets"`
	} `json:"aggregations"`
}

Jump to

Keyboard shortcuts

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