esutils

package
v0.0.0-...-d2a8444 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetResults

func GetResults[T any](
	es *elasticsearch.Client,
	o ...func(*esapi.SearchRequest),
) ([]T, error)

GetResults returns the search results from an ES search

func StoreDocument

func StoreDocument(
	ctx context.Context,
	es *elasticsearch.Client,
	index string,
	documentID string,
	document interface{},
	refresh bool,
) error

StoreDocument stores a single document on an ES index

Types

type ESError

type ESError struct {
	Error ErrorData `json:"error"`
}

type ESResult

type ESResult[T any] struct {
	Took    int64       `json:"took"`
	TimeOut bool        `json:"timed_out"`
	Shards  ShardsData  `json:"_shards"`
	Hits    HitsData[T] `json:"hits"`
}

type ErrorData

type ErrorData struct {
	Type   string `json:"type"`
	Reason string `json:"reason"`
}

type Hit

type Hit[T any] struct {
	Index  string  `json:"_index"`
	ID     string  `json:"_id"`
	Score  float64 `json:"_score"`
	Source T       `json:"_source"`
}

type HitsData

type HitsData[T any] struct {
	MaxScore float64    `json:"max_score"`
	Hits     []Hit[T]   `json:"hits"`
	Total    *TotalData `json:"total"`
}

type ShardsData

type ShardsData struct {
	Total      int64 `json:"total"`
	Successful int64 `json:"successful"`
	Skipped    int64 `json:"skipped"`
	Failed     int64 `json:"failed"`
}

type TotalData

type TotalData struct {
	Value    int64  `json:"value"`
	Relation string `json:"relation"`
}

Jump to

Keyboard shortcuts

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