elastic

package
v1.1.62 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMultiMatchSearchPrefix = errors.New("MultiMatchSearchPrefix response error")
)

Functions

func BulkIndex added in v1.1.54

func BulkIndex(ctx context.Context, transport esapi.Transport, index, documentID string, v []any) (*esapi.Response, error)

func CreateAlias added in v1.1.59

func CreateAlias(ctx context.Context, esClient *elasticsearch.Client, indexes []string, name string, data []byte) (*esapi.Response, error)

func CreateIndex added in v1.1.59

func CreateIndex(ctx context.Context, esClient *elasticsearch.Client, name string, data []byte) (*esapi.Response, error)

func Delete

func Delete(ctx context.Context, transport esapi.Transport, index, documentID string) (*esapi.Response, error)

func Exists added in v1.1.59

func Exists(ctx context.Context, esClient *elasticsearch.Client, indexes []string) (*esapi.Response, error)

func Index

func Index(ctx context.Context, transport esapi.Transport, index, documentID string, v any) (*esapi.Response, error)

func Info

func Info(ctx context.Context, esClient *elasticsearch.Client) (*esapi.Response, error)

func Int32Pointer

func Int32Pointer(v int32) *int32

func Int64Pointer

func Int64Pointer(v int64) *int64

func IntPointer

func IntPointer(v int) *int

func MappingIndex added in v1.1.59

func MappingIndex(ctx context.Context, esClient *elasticsearch.Client, indexName string, mapping []byte) error

func NewElasticSearchClient

func NewElasticSearchClient(cfg *common_utils.BaseConfig) (*elasticsearch.Client, error)
func Search(ctx context.Context, esClient *elasticsearch.Client, index string, data any) (*esapi.Response, error)

func StringPointer

func StringPointer(v string) *string

func Update

func Update(ctx context.Context, transport esapi.Transport, index, documentID string, document any) (*esapi.Response, error)

Types

type Bool added in v1.1.59

type Bool struct {
	Must []any `json:"must"`
}

type Doc

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

Doc is update request wrapper for any json serializable data

type ElasticIndex added in v1.1.59

type ElasticIndex struct {
	Path  string `mapstructure:"path" validate:"required"`
	Name  string `mapstructure:"name" validate:"required"`
	Alias string `mapstructure:"alias" validate:"required"`
}

func (*ElasticIndex) String added in v1.1.59

func (e *ElasticIndex) String() string

type EsHits

type EsHits[T any] struct {
	Hits struct {
		Total struct {
			Value int64 `json:"value"`
		} `json:"total"`
		Hits []struct {
			Source T         `json:"_source"`
			Sort   []float64 `json:"sort"`
		} `json:"hits"`
	} `json:"hits"`
}

type GetResponse

type GetResponse[T any] struct {
	Index       string `json:"_index"`
	Id          string `json:"_id"`
	Version     int    `json:"_version"`
	SeqNo       int    `json:"_seq_no"`
	PrimaryTerm int    `json:"_primary_term"`
	Found       bool   `json:"found"`
	Source      T      `json:"_source"`
}

type MultiMatch

type MultiMatch struct {
	Fields []string `json:"fields"`
	Query  string   `json:"query"`
	Type   string   `json:"type"`
}

type MultiMatchQuery

type MultiMatchQuery struct {
	MultiMatch MultiMatch `json:"multi_match"`
}

type MultiMatchSearchQuery

type MultiMatchSearchQuery struct {
	Query MultiMatchQuery `json:"query"`
	Sort  []any           `json:"sort"`
}

type SearchListResponse

type SearchListResponse[T any] struct {
	List  []T   `json:"list"`
	Total int64 `json:"total"`
}

func SearchMatchPhrasePrefix

func SearchMatchPhrasePrefix[T any](ctx context.Context, transport esapi.Transport, request SearchMatchPrefixRequest) (*SearchListResponse[T], error)

func SearchMultiMatchPrefix

func SearchMultiMatchPrefix[T any](ctx context.Context, transport esapi.Transport, request SearchMatchPrefixRequest) (*SearchListResponse[T], error)

type SearchMatchPrefixRequest

type SearchMatchPrefixRequest struct {
	Index   []string
	Term    string
	Size    int
	From    int
	Sort    []string
	Fields  []string
	SortMap map[string]any
}

type SearchOptions

type SearchOptions struct {
	Size   int
	From   int
	Sort   []string
	Fields []string
}

Jump to

Keyboard shortcuts

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