es

package
v1.22.16 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Zlib Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Agg

func Agg(ctx context.Context, client *elastic.Client, csr *Query, agg elastic.Aggregation, valueFunc func(json.RawMessage) error) (err error)

Agg 统计

func BatchAdd

func BatchAdd[T any](ctx context.Context, client *elastic.Client, index string, datas map[string]T, refresh string) error

func BatchDelete

func BatchDelete(ctx context.Context, client *elastic.Client, index string, ids []string, refresh string) error

func BatchUpdate

func BatchUpdate(ctx context.Context, client *elastic.Client, index string, datas map[string]map[string]interface{}, refresh string) error

func BuildExistsQuery

func BuildExistsQuery(name string) (query *elastic.ExistsQuery)

func BuildIntTermsQuery

func BuildIntTermsQuery(name string, list []int64) (query *elastic.TermsQuery)

func BuildNestedTermsQuery

func BuildNestedTermsQuery[T any](path string, name string, list []T) (query *elastic.NestedQuery)

func BuildNestedWildcardQuery

func BuildNestedWildcardQuery(path string, name string, card string) (query *elastic.NestedQuery)

func BuildQuery

func BuildQuery(ctx context.Context, client *elastic.Client, filter *Query) (*elastic.SearchService, error)

func BuildTermQuery

func BuildTermQuery[T any](name string, val T) (query *elastic.TermQuery)

func BuildTermsQuery

func BuildTermsQuery[T any](name string, list []T) (query *elastic.TermsQuery)

func BuildWildcardQuery

func BuildWildcardQuery(names []string, term string) (query *elastic.BoolQuery)

func NotFoundErr added in v1.22.10

func NotFoundErr(err error) bool
func Search(ctx context.Context, client *elastic.Client, filter *Query, valueFunc func(*elastic.SearchHit)) (int64, error)

Search ES搜索

func SearchAny

func SearchAny[T any](ctx context.Context, client *elastic.Client, filter *Query) ([]*T, int64, error)

SearchAny ES搜索

func UpdateWhere

func UpdateWhere(ctx context.Context, client *elastic.Client, csr *Query, data map[string]interface{}, refresh string) error

UpdateWhere 根据查询更新

Types

type Query added in v1.22.10

type Query struct {
	Index        string
	MustQuery    []elastic.Query
	MustNotQuery []elastic.Query
	ShouldQuery  []elastic.Query
	Filters      []elastic.Query
	Sorters      []elastic.Sorter
	PageIndex    int
	Size         int
	MaxWindows   int
}

func MustTermsQueryIf

func MustTermsQueryIf[T any](ok bool, search *Query, name string, list []T) *Query

func (*Query) ExistsQueryIf added in v1.22.10

func (cs *Query) ExistsQueryIf(ok bool, name string) *Query

func (*Query) FilterDeleteQuery added in v1.22.10

func (cs *Query) FilterDeleteQuery() *Query

FilterDeleteQuery 过滤删除的

func (*Query) FilterDeleteQueryIf added in v1.22.10

func (cs *Query) FilterDeleteQueryIf(filterDel bool) *Query

func (*Query) MustBitScriptQueryIf added in v1.22.10

func (cs *Query) MustBitScriptQueryIf(ok bool, name string, val int32) *Query

MustBitScriptQueryIf 位运算

func (*Query) MustNotTermQueryIf added in v1.22.10

func (cs *Query) MustNotTermQueryIf(ok bool, name string, term interface{}) *Query

func (*Query) MustRangeFromQueryIf added in v1.22.10

func (cs *Query) MustRangeFromQueryIf(ok bool, name string, from int64, optType int64) *Query

MustRangeFromQueryIf optType 1 gt 2 gte 3 lt 4 lte

func (*Query) MustTermQueryIf added in v1.22.10

func (cs *Query) MustTermQueryIf(ok bool, name string, term interface{}) *Query

func (*Query) MustTermsQueryIf added in v1.22.10

func (cs *Query) MustTermsQueryIf(ok bool, name string, list []string) *Query

func (*Query) MustTermsQueryInt32If added in v1.22.10

func (cs *Query) MustTermsQueryInt32If(ok bool, name string, list []int32) *Query

func (*Query) MustTermsQueryIntIf added in v1.22.10

func (cs *Query) MustTermsQueryIntIf(ok bool, name string, list []int) *Query

func (*Query) MustTermsUint8QueryIf added in v1.22.10

func (cs *Query) MustTermsUint8QueryIf(ok bool, name string, list []uint8) *Query

func (*Query) MustWildcardOrQueryIf added in v1.22.10

func (cs *Query) MustWildcardOrQueryIf(ok bool, names []string, term string) *Query

MustWildcardOrQueryIf 多字段模糊匹配, 用bool query.should 拼接or 条件

func (*Query) MustWildcardQueryIf added in v1.22.10

func (cs *Query) MustWildcardQueryIf(ok bool, name string, term string) *Query

func (*Query) Sort added in v1.22.10

func (cs *Query) Sort(list []*SortField, dft *SortField) *Query

func (*Query) ToQuery added in v1.22.10

func (cs *Query) ToQuery() elastic.Query

func (*Query) TryMustIntTermsQuery added in v1.22.10

func (cs *Query) TryMustIntTermsQuery(name string, list []int64) *Query

func (*Query) TryMustNestedInt32TermsQuery added in v1.22.10

func (cs *Query) TryMustNestedInt32TermsQuery(path string, name string, list []int32) *Query

TryMustNestedInt32TermsQuery 如 (path:to,name:to.id)

func (*Query) TryMustNestedStringTermsQuery added in v1.22.10

func (cs *Query) TryMustNestedStringTermsQuery(path string, name string, list []string) *Query

TryMustNestedStringTermsQuery 如 (path:to,name:to.id)

func (*Query) TryMustNestedWildcardQuery added in v1.22.10

func (cs *Query) TryMustNestedWildcardQuery(path string, name string, card string) *Query

TryMustNestedWildcardQuery 如 (path:to,name:to.id)

func (*Query) TryMustNotTermsQuery added in v1.22.10

func (cs *Query) TryMustNotTermsQuery(name string, list []string) *Query

func (*Query) TryMustRangeQuery added in v1.22.10

func (cs *Query) TryMustRangeQuery(name string, from int64, to int64) *Query

func (*Query) TryMustTermsQuery added in v1.22.10

func (cs *Query) TryMustTermsQuery(name string, list []string) *Query

type SortField

type SortField struct {
	OrderField string `json:"order_field"`
	Desc       bool   `json:"desc"`
}

Jump to

Keyboard shortcuts

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