Documentation ¶
Index ¶
- Constants
- Variables
- func CoreFrmCtx(ctx context.Context, id string) *elastic.Client
- func GetDbTX(id string) contextex.ContextKey
- func NewContext(ctx context.Context, id string, newdb *elastic.Client) context.Context
- func NewElasticClient(urls ...string) (*elastic.Client, error)
- func NewLogger() elastic.Logger
- func ParseHit[T dependency.IEntity](h *elastic.SearchHit) *T
- func WithContext(ctx context.Context, id string) *elastic.Client
- func WithQuery(conds ...any) elastic.Query
- func WithSort(sorts ...dependency.ISortField) []elastic.Sorter
- type BaseLogger
- type BaseRepository
- func (r *BaseRepository[T]) BaseCount(ctx context.Context, opts ...dependency.BaseOptionFunc) (int64, error)
- func (r *BaseRepository[T]) BaseCreate(ctx context.Context, ts []*T, opts ...dependency.BaseOptionFunc) (int64, error)
- func (r *BaseRepository[T]) BaseCreateOne(ctx context.Context, t *T, opts ...dependency.BaseOptionFunc) (int64, error)
- func (r *BaseRepository[T]) BaseCreates(ctx context.Context, ts []*T, opts ...dependency.BaseOptionFunc) (int64, error)
- func (r *BaseRepository[T]) BaseDelete(ctx context.Context, t *T, opts ...dependency.BaseOptionFunc) (int64, error)
- func (r *BaseRepository[T]) BaseGet(ctx context.Context, opts ...dependency.BaseOptionFunc) (*T, error)
- func (r *BaseRepository[T]) BaseQuery(ctx context.Context, opts ...dependency.BaseOptionFunc) ([]T, error)
- func (r *BaseRepository[T]) BaseQueryWithCount(ctx context.Context, opts ...dependency.BaseOptionFunc) ([]T, int64, error)
- func (r *BaseRepository[T]) BaseSave(ctx context.Context, ts []*T, opts ...dependency.BaseOptionFunc) (int64, error)
- func (r *BaseRepository[T]) BaseSearch(ctx context.Context, opts ...dependency.BaseOptionFunc) ([]T, int64, error)
- func (r *BaseRepository[T]) BaseTableCreate(ctx context.Context, opts ...dependency.BaseOptionFunc) (int64, error)
- func (r *BaseRepository[T]) BaseTableExists(ctx context.Context, opts ...dependency.BaseOptionFunc) (bool, error)
- func (r *BaseRepository[T]) BaseUpdate(ctx context.Context, t *T, opts ...dependency.BaseOptionFunc) (int64, error)
- func (r *BaseRepository[T]) GetCountService(ctx context.Context, opts ...dependency.BaseOptionFunc) *elastic.CountService
- func (r *BaseRepository[T]) GetDeleteService(ctx context.Context, opts ...dependency.BaseOptionFunc) *elastic.DeleteService
- func (r *BaseRepository[T]) GetGetService(ctx context.Context, opts ...dependency.BaseOptionFunc) *elastic.GetService
- func (r *BaseRepository[T]) GetIndexService(ctx context.Context, opts ...dependency.BaseOptionFunc) *elastic.IndexService
- func (r *BaseRepository[T]) GetIndicesCreateService(ctx context.Context, opts ...dependency.BaseOptionFunc) *elastic.IndicesCreateService
- func (r *BaseRepository[T]) GetSearchService(ctx context.Context, opts ...dependency.BaseOptionFunc) *elastic.SearchService
- func (r *BaseRepository[T]) GetSearchServiceFrmOpt(ctx context.Context, opt *dependency.BaseOption) *elastic.SearchService
- type BatchSpan
- type LimitSearch
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 GetDbTX ¶ added in v0.1.1
func GetDbTX(id string) contextex.ContextKey
func NewContext ¶ added in v0.1.1
func NewElasticClient ¶
func WithContext ¶ added in v0.1.1
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 ¶
func NeedPagingSpan ¶
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 ¶
Click to show internal directories.
Click to hide internal directories.