es

package
v1.20.51 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 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 *SearchQuery, 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) error

func BatchDelete

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

func BatchUpdate

func BatchUpdate(ctx context.Context, client *elastic.Client, index string, datas map[string]map[string]interface{}) 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 *SearchQuery) (*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 Search(ctx context.Context, client *elastic.Client, filter *SearchQuery, valueFunc func(*elastic.SearchHit)) (int64, error)

Search ES搜索

func SearchAny

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

SearchAny ES搜索

func UpdateWhere

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

UpdateWhere 根据查询更新

Types

type SearchQuery

type SearchQuery 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 *SearchQuery, name string, list []T) *SearchQuery

func (*SearchQuery) ExistsQueryIf

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

func (*SearchQuery) FilterDeleteQuery

func (cs *SearchQuery) FilterDeleteQuery() *SearchQuery

FilterDeleteQuery 过滤删除的

func (*SearchQuery) FilterDeleteQueryIf

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

func (*SearchQuery) MustBitScriptQueryIf

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

MustBitScriptQueryIf 位运算

func (*SearchQuery) MustNotTermQueryIf

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

func (*SearchQuery) MustRangeFromQueryIf

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

MustRangeFromQueryIf optType 1 gt 2 gte 3 lt 4 lte

func (*SearchQuery) MustTermQueryIf

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

func (*SearchQuery) MustTermsQueryIf

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

func (*SearchQuery) MustTermsQueryInt32If

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

func (*SearchQuery) MustTermsQueryIntIf

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

func (*SearchQuery) MustTermsUint8QueryIf

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

func (*SearchQuery) MustWildcardOrQueryIf

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

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

func (*SearchQuery) MustWildcardQueryIf

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

func (*SearchQuery) ToQuery

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

func (*SearchQuery) TryMustIntTermsQuery

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

func (*SearchQuery) TryMustNestedInt32TermsQuery

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

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

func (*SearchQuery) TryMustNestedStringTermsQuery

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

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

func (*SearchQuery) TryMustNestedWildcardQuery

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

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

func (*SearchQuery) TryMustNotTermsQuery

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

func (*SearchQuery) TryMustRangeQuery

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

func (*SearchQuery) TryMustTermsQuery

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

func (*SearchQuery) TrySort

func (cs *SearchQuery) TrySort(list []*SortField, dft *SortField) *SearchQuery

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