Documentation ¶
Index ¶
- Constants
- func CloseAll()
- func InitClient(clientName string, addr []string, username string, password string) error
- func InitClientWithCfg(clientName string, cfg elasticsearch.Config, queryLogEnable bool, bulk BulkCfg) error
- type BulkCfg
- type BulkIndexerOnFailure
- type Client
- func (c *Client) BulkDelete(ctx context.Context, indexName, id, routing string, ...) error
- func (c *Client) BulkDeleteWithSeqNo(ctx context.Context, indexName, id, routing string, sqNo, primaryTerm *int64, ...) error
- func (c *Client) BulkIndex(ctx context.Context, indexName, id, routing, jsonDoc string, ...) error
- func (c *Client) BulkInsert(ctx context.Context, indexName, id, routing, jsonDoc string, ...) error
- func (c *Client) BulkInsertWithSeqNo(ctx context.Context, id, routing, indexName, action, jsonDoc string, ...) error
- func (c *Client) BulkUpdate(ctx context.Context, indexName, id, routing string, ...) error
- func (c *Client) Close(ctx context.Context) error
- func (c *Client) CreateIndex(ctx context.Context, indexName, bodyJson string, forceCheck bool) error
- func (c *Client) Delete(ctx context.Context, indexName, id, routing string) (*delete.Response, error)
- func (c *Client) DeleteByQuery(ctx context.Context, indexName, routing, preference string, query *types.Query) (*deletebyquery.Response, error)
- func (c *Client) DeleteIndex(ctx context.Context, indexName string) (*delete.Response, error)
- func (c *Client) DeleteWithSeqNo(ctx context.Context, indexName, id, routing, seqNo, primaryTerm string) (*delete.Response, error)
- func (c *Client) Get(ctx context.Context, indexName, id, routing, preference string, ...) (*get.Response, error)
- func (c *Client) IndexExists(ctx context.Context, indexName string, forceCheck bool) (bool, error)
- func (c *Client) Insert(ctx context.Context, indexName, id, routing, action string, doc interface{}) (*index.Response, error)
- func (c *Client) Mget(ctx context.Context, indexName, routing string, ids, excludes []string) (*mget.Response, error)
- func (c *Client) Query(ctx context.Context, indexName string, routing string, query *types.Query, ...) (*search.Response, error)
- func (c *Client) ScrollQuery(ctx context.Context, indexName string, routing string, query *types.Query, ...) error
- func (c *Client) Update(ctx context.Context, indexName, id, routing string, ...) (*update.Response, error)
- func (c *Client) UpdateByQuery(ctx context.Context, indexName string, routing, preference string, ...) (*updatebyquery.Response, error)
- func (c *Client) Upsert(ctx context.Context, indexName, id, routing string, ...) (*update.Response, error)
- type Mget
- type QueryOption
- func WithEnableDSL(enableDSL bool) QueryOption
- func WithExcludeFields(excludeFields []string) QueryOption
- func WithFetchSource(fetchSource bool) QueryOption
- func WithHighlight(highlight *types.Highlight) QueryOption
- func WithIncludeFields(includeFields []string) QueryOption
- func WithOrders(orders []map[string]bool) QueryOption
- func WithPreference(preference string) QueryOption
- func WithProfile(profile bool) QueryOption
- func WithSlowQueryMillisecond(slowQueryLogMillisecond int64) QueryOption
Constants ¶
View Source
const ( DefaultClient = "es-default-client" DefaultReadClient = "es-default-read-client" DefaultWriteClient = "es-default-write-client" )
View Source
const ( DefaultVersionType = "external" VersionTypeInternal = "internal" DefaultRefresh = "false" RefreshWaitFor = "wait_for" RefreshTrue = "true" DefaultScriptLang = "painless" Bulk OptypeCreate = "create" OptypeIndex = "index" OptypeUpsert = "upsert" OptypeUpdate = "update" OptypeDelete = "delete" )
View Source
const DefaultPreference = "_local"
Variables ¶
This section is empty.
Functions ¶
func InitClient ¶
Types ¶
type BulkIndexerOnFailure ¶
type BulkIndexerOnFailure func(context.Context, esutil.BulkIndexerItem, esutil.BulkIndexerResponseItem, error)
type Client ¶
type Client struct { Name string Addr []string QueryLogEnable bool Username string BulkCfg *BulkCfg Client *elasticsearch.TypedClient BulkProcessor esutil.BulkIndexer DebugMode bool //本地缓存已经创建的索引,用于加速索引是否存在的判断 CachedIndices sync.Map // contains filtered or unexported fields }
func (*Client) BulkDelete ¶
func (*Client) BulkDeleteWithSeqNo ¶
func (*Client) BulkIndex ¶
func (c *Client) BulkIndex(ctx context.Context, indexName, id, routing, jsonDoc string, onFailure BulkIndexerOnFailure) error
批量的方式新建文档(覆盖写),后台提交
func (*Client) BulkInsert ¶
func (c *Client) BulkInsert(ctx context.Context, indexName, id, routing, jsonDoc string, onFailure BulkIndexerOnFailure) error
批量的方式新建文档,后台提交
func (*Client) BulkInsertWithSeqNo ¶
func (c *Client) BulkInsertWithSeqNo(ctx context.Context, id, routing, indexName, action, jsonDoc string, seqNo, primaryTerm *int64, onFailure BulkIndexerOnFailure) error
seqNo primaryTerm 用于更新文档,通过SeqNo和PrimaryTerm来保证更新操作的顺序性,避免冲突
func (*Client) BulkUpdate ¶
func (*Client) CreateIndex ¶
func (c *Client) CreateIndex(ctx context.Context, indexName, bodyJson string, forceCheck bool) error
创建索引
func (*Client) DeleteByQuery ¶
func (c *Client) DeleteByQuery(ctx context.Context, indexName, routing, preference string, query *types.Query) (*deletebyquery.Response, error)
删除过程中如果命中的文档被修改会导致删除出现版本冲突,为了彻底删除文档,需要指定ProceedOnVersionConflict
func (*Client) DeleteIndex ¶
删除索引
func (*Client) DeleteWithSeqNo ¶
func (*Client) IndexExists ¶
检查索引是否存在
func (*Client) Insert ¶
func (c *Client) Insert(ctx context.Context, indexName, id, routing, action string, doc interface{}) (*index.Response, error)
新建文档
func (*Client) ScrollQuery ¶
func (*Client) UpdateByQuery ¶
type QueryOption ¶
type QueryOption func(queryOption *queryOption)
func WithEnableDSL ¶
func WithEnableDSL(enableDSL bool) QueryOption
func WithExcludeFields ¶
func WithExcludeFields(excludeFields []string) QueryOption
func WithFetchSource ¶
func WithFetchSource(fetchSource bool) QueryOption
func WithHighlight ¶
func WithHighlight(highlight *types.Highlight) QueryOption
func WithIncludeFields ¶
func WithIncludeFields(includeFields []string) QueryOption
func WithOrders ¶
func WithOrders(orders []map[string]bool) QueryOption
func WithPreference ¶
func WithPreference(preference string) QueryOption
func WithProfile ¶
func WithProfile(profile bool) QueryOption
func WithSlowQueryMillisecond ¶
func WithSlowQueryMillisecond(slowQueryLogMillisecond int64) QueryOption
Click to show internal directories.
Click to hide internal directories.