es_util

package module
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Int64ArrToInterfaceArray

func Int64ArrToInterfaceArray(a []int64) []interface{}

func MakeBulkESRequest

func MakeBulkESRequest(es *elastic.Client, bulkSize, limit int,
	reqGap time.Duration, makeSingleRequest SingleReqMaker) (int, error)

MakeBulkESRequest 分批执行 ES 的批量请求,避免 payload 过大造成集群宕机

bulkSize 最终插入的总数据量, limit 为每批批量插入的数据量, reqGap 为每批插入的时间间隔, makeSingleRequest 应按数据的序号返回对应的每个批量请求的具体内容, 返回成功的数量

func MakeBulkESRequestIgnoreConflict added in v0.1.1

func MakeBulkESRequestIgnoreConflict(es *elastic.Client, bulkSize, limit int,
	reqGap time.Duration, makeSingleRequest SingleReqMaker) (int, error)

MakeBulkESRequestIgnoreConflict 分批执行 ES 的批量请求,忽略版本冲突, 避免 payload 过大造成集群宕机

bulkSize 最终插入的总数据量, limit 为每批批量插入的数据量, reqGap 为每批插入的时间间隔, makeSingleRequest 应按数据的序号返回对应的每个批量请求的具体内容, 返回成功的数量

func MakeRequest added in v0.3.0

func MakeRequest(es *elastic.Client, bulkSize int, makeSingleRequest SingleReqMaker) (successCount int, err error)

MakeRequest 分批执行 ES 的批量请求,避免 payload 过大造成集群宕机,每批 1k, 间隔 1s

func MakeRequestWithOpt added in v0.3.0

func MakeRequestWithOpt(es *elastic.Client, bulkSize int, opt BulkOpt,
	makeSingleRequest SingleReqMaker) (successCount int, err error)

func ParseBulkResponse

func ParseBulkResponse(resp *elastic.BulkResponse) (int, error)

func ParseBulkResponseIgnoreConflict added in v0.1.1

func ParseBulkResponseIgnoreConflict(resp *elastic.BulkResponse) (int, error)

func ParseBulkResponseIgnoreDocMiss added in v0.3.3

func ParseBulkResponseIgnoreDocMiss(resp *elastic.BulkResponse) (int, error)

func SearchWithExport added in v0.3.1

func SearchWithExport(makeService func() *elastic.SearchService, export bool) (*elastic.SearchResult, error)

func StrArrToInterfaceArray

func StrArrToInterfaceArray(a []string) []interface{}

Types

type BulkOpt added in v0.3.0

type BulkOpt struct {
	Limit          int           // 每批数据量 默认 1000
	Gap            time.Duration // 每批插入的时间间隔 默认 1s
	Refresh        string        // 是否 refresh 默认 false
	IgnoreConflict bool          // 是否忽略冲突 默认 false
	IgnoreDocMiss  bool          // 是否忽略文档不存在 默认 false
}

type SingleReqMaker added in v0.3.0

type SingleReqMaker func(int) elastic.BulkableRequest

Jump to

Keyboard shortcuts

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