Documentation ¶
Index ¶
- func CreateDefaultESClient() error
- func NewESClient(cfg *Config) (*elasticv7.Client, error)
- func NewStarter() *starter
- func XClient() *elasticv7.Client
- func XFClient(f func(c *elasticv7.Client) error) error
- type Config
- type EsCommonDoc
- func (c *EsCommonDoc) AddDoc(docId, esType, esIndex string, doc interface{}) (*elasticv7.IndexResponse, error)
- func (c *EsCommonDoc) BatchAddDoc(esIndex, esType string, datas ...interface{}) error
- func (c *EsCommonDoc) DeleteDoc(docId, esType, esIndex string) (*elasticv7.DeleteResponse, error)
- func (c *EsCommonDoc) GetDoc(docId, esIndex string) (*elasticv7.GetResult, error)
- func (c *EsCommonDoc) IsDocExists(docId, esType, esIndex string) (bool, error)
- func (c *EsCommonDoc) UpdateDoc(updateField *map[string]interface{}, docId, esType, esIndex string) (*elasticv7.UpdateResponse, error)
- type EsCommonSearch
- func (c *EsCommonSearch) MultiSearch(ctx context.Context, esIndex string, requests ...*elasticv7.SearchRequest) (*elasticv7.MultiSearchResult, error)
- func (c *EsCommonSearch) Search(ctx context.Context, esIndex, esType string, query elasticv7.Query) (*elasticv7.SearchResult, error)
- func (c *EsCommonSearch) SearchShards(ctx context.Context, indies ...string) (*elasticv7.SearchShardsResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { URL string // 服务地址 Username string // 鉴权用户名 Password string // 鉴权密码 Sniff bool // 启用或禁用嗅探器。 Healthcheck bool // 启用连接健康检查 Infolog string // Info级别日志记录文件路径 Errorlog string // Error级别日志记录文件路径 Tracelog string // Trace级别日志记录文件路径 }
func DefaultConfig ¶
func DefaultConfig() *Config
type EsCommonDoc ¶
type EsCommonDoc struct {
// contains filtered or unexported fields
}
一些常用的文档操作方法
func XCommonDoc ¶
func XCommonDoc() *EsCommonDoc
func (*EsCommonDoc) AddDoc ¶
func (c *EsCommonDoc) AddDoc(docId, esType, esIndex string, doc interface{}) (*elasticv7.IndexResponse, error)
添加文档
func (*EsCommonDoc) BatchAddDoc ¶
func (c *EsCommonDoc) BatchAddDoc(esIndex, esType string, datas ...interface{}) error
批量插入
func (*EsCommonDoc) DeleteDoc ¶
func (c *EsCommonDoc) DeleteDoc(docId, esType, esIndex string) (*elasticv7.DeleteResponse, error)
删除文档
func (*EsCommonDoc) GetDoc ¶
func (c *EsCommonDoc) GetDoc(docId, esIndex string) (*elasticv7.GetResult, error)
获取文档
func (*EsCommonDoc) IsDocExists ¶
func (c *EsCommonDoc) IsDocExists(docId, esType, esIndex string) (bool, error)
查看某文档是否存在,给定文档ID查询
func (*EsCommonDoc) UpdateDoc ¶
func (c *EsCommonDoc) UpdateDoc(updateField *map[string]interface{}, docId, esType, esIndex string) (*elasticv7.UpdateResponse, error)
更新文档
type EsCommonSearch ¶
type EsCommonSearch struct {
// contains filtered or unexported fields
}
一些常用的搜索方法
func XCommonSearch ¶
func XCommonSearch() *EsCommonSearch
func (*EsCommonSearch) MultiSearch ¶
func (c *EsCommonSearch) MultiSearch(ctx context.Context, esIndex string, requests ...*elasticv7.SearchRequest) (*elasticv7.MultiSearchResult, error)
func (*EsCommonSearch) Search ¶
func (c *EsCommonSearch) Search(ctx context.Context, esIndex, esType string, query elasticv7.Query) (*elasticv7.SearchResult, error)
func (*EsCommonSearch) SearchShards ¶
func (c *EsCommonSearch) SearchShards(ctx context.Context, indies ...string) (*elasticv7.SearchShardsResponse, error)
Click to show internal directories.
Click to hide internal directories.