elasticsearch

package
v3.0.10 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SortAsc  = `asc`
	SortDesc = `desc`
)

Variables

View Source
var (
	ErrArgsEmpty       = errors.New("args is empty")
	ErrSetterEmpty     = errors.New("setter is empty")
	ErrPropertiesEmpty = errors.New("properties is empty")
	ErrIndexNotExists  = errors.New("no such index")
)
View Source
var (
	DefaultPageSize int64 = 15
)

Functions

This section is empty.

Types

type Arg

type Arg struct {
	// contains filtered or unexported fields
}

func WithArg

func WithArg(key string, value any) Arg

type Body

type Body kind.JsonParam

func (Body) Marshal

func (b Body) Marshal() (body []byte, err error)

func (Body) WithArgs

func (b Body) WithArgs(args ...Arg)

func (Body) WithCursor

func (b Body) WithCursor(cursor string)

func (Body) WithFetchSize

func (b Body) WithFetchSize(size int64)

func (Body) WithProperties

func (b Body) WithProperties(properties result.MappingProperties)

func (Body) WithQuery

func (b Body) WithQuery(query any)

func (Body) WithSql

func (b Body) WithSql(sqlStr string, args ...any)

type BulkCreate

type BulkCreate struct {
	// contains filtered or unexported fields
}

func (*BulkCreate) Marshal

func (bc *BulkCreate) Marshal() []byte

type BulkDelete

type BulkDelete struct {
	// contains filtered or unexported fields
}

func (*BulkDelete) Marshal

func (bc *BulkDelete) Marshal() []byte

type BulkIndex

type BulkIndex struct {
	// contains filtered or unexported fields
}

func (*BulkIndex) Marshal

func (bi *BulkIndex) Marshal() []byte

type BulkItem

type BulkItem struct {
	// contains filtered or unexported fields
}

func NewBulkItem

func NewBulkItem(items ...BulkMarshal) *BulkItem

func (*BulkItem) Marshal

func (bi *BulkItem) Marshal() []byte

func (*BulkItem) WithCreate

func (bi *BulkItem) WithCreate(index, id string, property Property) *BulkItem

func (*BulkItem) WithDelete

func (bi *BulkItem) WithDelete(index, id string) *BulkItem

func (*BulkItem) WithIndex

func (bi *BulkItem) WithIndex(index, id string, property Property) *BulkItem

func (*BulkItem) WithUpdate

func (bi *BulkItem) WithUpdate(index, id string, property Updater) *BulkItem

type BulkMarshal

type BulkMarshal interface {
	Marshal() []byte
}

type BulkUpdate

type BulkUpdate struct {
	// contains filtered or unexported fields
}

func (*BulkUpdate) Marshal

func (bu *BulkUpdate) Marshal() []byte

type Options

type Options struct {
	BaseUrl            string `json:"baseUrl" yaml:"baseUrl"`
	UserName           string `json:"userName" yaml:"userName"`
	Password           string `json:"password" yaml:"password"`
	MaxIdleConns       int    `json:"maxIdleConns" yaml:"maxIdleConns"`
	MaxOpenConns       int    `json:"maxOpenConns" yaml:"maxOpenConns"`
	TimeoutSec         int    `json:"timeoutSec" yaml:"timeoutSec"`
	DialTimeoutSec     int    `json:"dialTimeoutSec" yaml:"dialTimeoutSec"`
	KeepaliveSec       int    `json:"keepaliveSec" yaml:"keepaliveSec"`
	ConnMaxIdleTimeSec int    `json:"connMaxIdleTimeSec" yaml:"connMaxIdleTimeSec"`
	ConnMaxLifetimeSec int    `json:"connMaxLifetimeSec" yaml:"connMaxLifetimeSec"`
	ReadBufferSize     int    `json:"readBufferSize" yaml:"readBufferSize"`
	WriteBufferSize    int    `json:"writeBufferSize" yaml:"writeBufferSize"`
}

func DefaultOption

func DefaultOption() Options

func OptionsWithJson

func OptionsWithJson(conf string) (opt Options, err error)

func OptionsWithYaml

func OptionsWithYaml(conf string) (opt Options, err error)

func (*Options) ConnMaxIdleTime

func (o *Options) ConnMaxIdleTime() time.Duration

func (*Options) ConnMaxLifetime

func (o *Options) ConnMaxLifetime() time.Duration

func (*Options) DialTimeout

func (o *Options) DialTimeout() time.Duration

func (*Options) KeepaliveTime

func (o *Options) KeepaliveTime() time.Duration

func (*Options) Timeout

func (o *Options) Timeout() time.Duration

type OrderItem

type OrderItem struct {
	Order  string `json:"order"`
	Format string `json:"format,omitempty"`
	Mode   string `json:"mode,omitempty"`
}

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

func NewPool

func NewPool(opt Options) (pool *Pool)

func (*Pool) Bulk

func (p *Pool) Bulk(ctx context.Context, bi *BulkItem) (res *result.Bulk, err error)

func (*Pool) CloseSqlCursor

func (p *Pool) CloseSqlCursor(ctx context.Context, cursor string) (response *http_client.Response, err error)

func (*Pool) DocDel

func (p *Pool) DocDel(ctx context.Context, indexName, id string) (res *result.DocIndex, err error)

func (*Pool) DocFieldIncr

func (p *Pool) DocFieldIncr(ctx context.Context, indexName, id, field string, increment int64) (res *result.DocIndex, err error)

func (*Pool) DocIndex

func (p *Pool) DocIndex(ctx context.Context, indexName string, body Body) (res *result.DocIndex, err error)

func (*Pool) DocIndexWithId

func (p *Pool) DocIndexWithId(ctx context.Context, indexName, id string, body Body) (res *result.DocIndex, err error)

func (*Pool) DocMGet

func (p *Pool) DocMGet(ctx context.Context, indexName string, idList ...string) (res *result.Documents, err error)

func (*Pool) DocUpdate

func (p *Pool) DocUpdate(ctx context.Context, indexName, id string, setter Setter) (res *result.DocIndex, err error)

func (*Pool) DocUpdateWithOptimistic

func (p *Pool) DocUpdateWithOptimistic(ctx context.Context, indexName, id string, setter Setter, seqNo, primaryTerm int64) (res *result.DocIndex, err error)

func (*Pool) Index

func (p *Pool) Index(ctx context.Context, name string, args ...Arg) (res *result.Index, err error)

func (*Pool) IndexDel

func (p *Pool) IndexDel(ctx context.Context, name string) (res *result.Index, err error)

func (*Pool) IndexMapping

func (p *Pool) IndexMapping(ctx context.Context, name string, properties result.MappingProperties) (res *result.Index, err error)

func (*Pool) IndexMappingGet

func (p *Pool) IndexMappingGet(ctx context.Context, target string) (res *result.IndexMapping, err error)

func (*Pool) IndexSetting

func (p *Pool) IndexSetting(ctx context.Context, name string, args ...Arg) (res *result.Index, err error)

func (*Pool) IndexSettingGet

func (p *Pool) IndexSettingGet(ctx context.Context, target string) (response *http_client.Response, err error)

func (*Pool) Options

func (p *Pool) Options() Options

func (*Pool) QueryWithCursor

func (p *Pool) QueryWithCursor(ctx context.Context, cursor, format string, args ...Arg) (res *result.Sql, err error)

func (*Pool) QueryWithDsl

func (p *Pool) QueryWithDsl(ctx context.Context, indexName string, qs *QueryDsl) (*result.Search, error)

func (*Pool) QueryWithString

func (p *Pool) QueryWithString(ctx context.Context, indexName string, qs *QueryString) (*result.Search, error)

func (*Pool) Request

func (p *Pool) Request(ctx context.Context, method, path string, body []byte, headers http_client.Headers) (response *http_client.Response, err error)

func (*Pool) SearchBySql

func (p *Pool) SearchBySql(ctx context.Context, size int64, format, sqlStr string, params []any, bodyArgs ...Arg) (res *result.Sql, err error)

type Properties

type Properties map[string]Property

func (Properties) WithProperty

func (p Properties) WithProperty(field string, prop Property)

type Property

type Property map[string]any

type QueryDsl

type QueryDsl struct {
	Query       kind.JsonParam `json:"query"`
	From        int64          `json:"from"`
	Size        int64          `json:"size"`
	Source      any            `json:"_source,omitempty"`
	Sort        Sort           `json:"sort,omitempty"`
	SearchAfter []any          `json:"search_after,omitempty"`
}

type QueryString

type QueryString struct {
	Query       StringQuery `json:"query"`
	From        int64       `json:"from"`
	Size        int64       `json:"size,omitempty"`
	Source      any         `json:"_source,omitempty"`
	Sort        Sort        `json:"sort,omitempty"`
	SearchAfter []any       `json:"search_after,omitempty"`
}

func NewQueryString

func NewQueryString(q string) *QueryString

func (*QueryString) SetQuery

func (qs *QueryString) SetQuery(q string) *QueryString

type Setter

type Setter map[string]any

func (Setter) ToBody

func (s Setter) ToBody() (setter []byte, err error)

type Sort

type Sort []SortItem

type SortItem

type SortItem map[string]OrderItem

type String

type String struct {
	Query string `json:"query"`
}

type StringQuery

type StringQuery struct {
	QueryString String `json:"query_string"`
}

type Updater

type Updater struct {
	Doc         Property `json:"doc,omitempty"`
	Script      Property `json:"script,omitempty"`
	DocAsUpsert bool     `json:"doc_as_upsert,omitempty"`
	Source      bool     `json:"_source,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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