elasticex

package
v0.3.62 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_WINDOW_SIZE = 10000
)
View Source
const (
	SqlLogFormat = "elapsed:%dms,affect:%d,err:%s,sql:%s"
)

Variables

View Source
var ElasticComponent = embedded.NewComponent[*elastic.Client]()

Functions

func CoreFrmCtx

func CoreFrmCtx(ctx context.Context, id string) *elastic.Client

CoreFrmCtx

func GetDbTX added in v0.1.1

func GetDbTX(id string) contextex.ContextKey

func NewContext added in v0.1.1

func NewContext(ctx context.Context, id string, newdb *elastic.Client) context.Context

func NewElasticClient

func NewElasticClient(urls ...string) (*elastic.Client, error)

func NewLogger

func NewLogger() elastic.Logger

func ParseHit

func ParseHit[T dependency.IEntity](h *elastic.SearchHit) *T

ParseHit

func WithContext added in v0.1.1

func WithContext(ctx context.Context, id string) *elastic.Client

func WithQuery

func WithQuery(conds ...any) elastic.Query

func WithSort

func WithSort(sorts ...dependency.ISortField) []elastic.Sorter

Types

type BaseLogger

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

func (*BaseLogger) Printf

func (l *BaseLogger) Printf(msg string, args ...interface{})

type BaseRepository

type BaseRepository[T dependency.IEntity] struct{} // base repository

func (*BaseRepository[T]) BaseCount

func (r *BaseRepository[T]) BaseCount(ctx context.Context, opts ...dependency.BaseOptionFunc) (int64, error)

BaseCount

func (*BaseRepository[T]) BaseCreate

func (r *BaseRepository[T]) BaseCreate(ctx context.Context, ts []*T, opts ...dependency.BaseOptionFunc) (int64, error)

BaseCreate

func (*BaseRepository[T]) BaseCreateOne

func (r *BaseRepository[T]) BaseCreateOne(ctx context.Context, t *T, opts ...dependency.BaseOptionFunc) (int64, error)

BaseCreate

func (*BaseRepository[T]) BaseCreates

func (r *BaseRepository[T]) BaseCreates(ctx context.Context, ts []*T, opts ...dependency.BaseOptionFunc) (int64, error)

BaseCreates

func (*BaseRepository[T]) BaseDelete

func (r *BaseRepository[T]) BaseDelete(ctx context.Context, t *T, opts ...dependency.BaseOptionFunc) (int64, error)

BaseDelete

func (*BaseRepository[T]) BaseGet

func (r *BaseRepository[T]) BaseGet(ctx context.Context, opts ...dependency.BaseOptionFunc) (*T, error)

BaseGet

func (*BaseRepository[T]) BaseQuery

func (r *BaseRepository[T]) BaseQuery(ctx context.Context, opts ...dependency.BaseOptionFunc) ([]T, error)

BaseQuery

func (*BaseRepository[T]) BaseQueryWithCount

func (r *BaseRepository[T]) BaseQueryWithCount(ctx context.Context, opts ...dependency.BaseOptionFunc) ([]T, int64, error)

BaseQuery

func (*BaseRepository[T]) BaseSave

func (r *BaseRepository[T]) BaseSave(ctx context.Context, ts []*T, opts ...dependency.BaseOptionFunc) (int64, error)

BaseSave

func (*BaseRepository[T]) BaseSearch

func (r *BaseRepository[T]) BaseSearch(ctx context.Context, opts ...dependency.BaseOptionFunc) ([]T, int64, error)

func (*BaseRepository[T]) BaseTableCreate

func (r *BaseRepository[T]) BaseTableCreate(ctx context.Context, opts ...dependency.BaseOptionFunc) (int64, error)

BaseTableCreate

func (*BaseRepository[T]) BaseTableExists

func (r *BaseRepository[T]) BaseTableExists(ctx context.Context, opts ...dependency.BaseOptionFunc) (bool, error)

BaseTableCreate

func (*BaseRepository[T]) BaseUpdate

func (r *BaseRepository[T]) BaseUpdate(ctx context.Context, t *T, opts ...dependency.BaseOptionFunc) (int64, error)

BaseUpdate

func (*BaseRepository[T]) GetCountService

func (r *BaseRepository[T]) GetCountService(ctx context.Context, opts ...dependency.BaseOptionFunc) *elastic.CountService

GetCountService

func (*BaseRepository[T]) GetDeleteService

func (r *BaseRepository[T]) GetDeleteService(ctx context.Context, opts ...dependency.BaseOptionFunc) *elastic.DeleteService

GetDeleteService

func (*BaseRepository[T]) GetGetService

func (r *BaseRepository[T]) GetGetService(ctx context.Context, opts ...dependency.BaseOptionFunc) *elastic.GetService

GetService

func (*BaseRepository[T]) GetIndexService

func (r *BaseRepository[T]) GetIndexService(ctx context.Context, opts ...dependency.BaseOptionFunc) *elastic.IndexService

GetIndexService

func (*BaseRepository[T]) GetIndicesCreateService

func (r *BaseRepository[T]) GetIndicesCreateService(ctx context.Context, opts ...dependency.BaseOptionFunc) *elastic.IndicesCreateService

GetIndicesCreateService

func (*BaseRepository[T]) GetSearchService

func (r *BaseRepository[T]) GetSearchService(ctx context.Context, opts ...dependency.BaseOptionFunc) *elastic.SearchService

GetSearchService

func (*BaseRepository[T]) GetSearchServiceFrmOpt

func (r *BaseRepository[T]) GetSearchServiceFrmOpt(ctx context.Context, opt *dependency.BaseOption) *elastic.SearchService

GetSearchService

type BatchSpan

type BatchSpan struct {
	IsSkip  bool
	Size    int64
	Anchors []interface{} // 锚点
}

func NeedPagingSpan

func NeedPagingSpan(need, batch int64, isSkip bool) []*BatchSpan

type LimitSearch

type LimitSearch struct {
	Limit int64 // 窗口搜索量限制

	Offset int64        // 偏移量,从多少点位开始获取数据
	Total  int64        // 总计量,总计获取数据量
	Spans  []*BatchSpan // 搜索分段
}

func (*LimitSearch) InitSpans

func (l *LimitSearch) InitSpans()

func (*LimitSearch) RepairSpans

func (l *LimitSearch) RepairSpans(realTotal int64)

RepairSpans 根据实际数据优化分段,减少无效查询次数

func (*LimitSearch) SearchByStep

func (l *LimitSearch) SearchByStep(f func(index, subCursor, subSize int64) ([]interface{}, int64, error)) ([]interface{}, int64, error)

Jump to

Keyboard shortcuts

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