Documentation ¶
Index ¶
- Constants
- func AliasAction(client *Client, aliasname string, actions []map[string]map[string]string) error
- func AliasActionWithPool(aliasname string, actions []map[string]map[string]string) error
- func AliasQuery(client *Client, aliasname string) ([]string, error)
- func AliasQueryWithPool(aliasname string) ([]string, error)
- func Create(client *Client, indexname string) bool
- func CreateWithPool(indexname string) bool
- func Del(client *Client, indexList []string) []string
- func DelWithPool(indexList []string) []string
- func Exist(client *Client, indexname string) bool
- func ExistWithPool(indexname string) bool
- func Flush(client *Client, indexname string) bool
- func FlushWithPool(indexname string) bool
- func GetTimeTemps(s string) string
- func NewPool(logger *zap.Logger, opt Option, size int) error
- func TempCreate(client *Client, name string, qdata []byte) error
- func TempCreateWithPool(name string, qdata []byte) error
- func TempExist(client *Client, name string) bool
- func TempExistWithPool(name string) bool
- type Ack
- type BulkClient
- type BulkOption
- type Client
- type ClientPool
- type EasyRequest
- type HitsResponse
- type Option
- type ReqParam
- type ScriptedMetric
- type SearchRequest
- type SearchResponse
- type SearchResult
Constants ¶
View Source
const ( HTTP_SELF_CODE = 900 // 自定义的http状态码边界 HTTP_REQ_FAIL = 901 // 请求发起就失败了, 不涉及响应 HTTP_RESP_READ_FAIL = 902 // 响应数据读取失败 ES_REJECTED_ERROR = "es_rejected_execution_exception" CONTENT_TYPE = "Content-Type" APPLICATION_JSON = "application/json" )
Variables ¶
This section is empty.
Functions ¶
func AliasAction ¶
AliasAction 执行alias操作
func AliasActionWithPool ¶
AliasActionWithPool 执行指定alias操作
func AliasQuery ¶
AliasQuery 查询当前指定alias配置
func AliasQueryWithPool ¶
AliasQueryWithPool 查询当前alias配置
func DelWithPool ¶
DelWithPool 删除指定index 返回删除失败的index列表
func ExistWithPool ¶
ExistWithPool 判断index是否存在 true => 存在, false => 不存在
func FlushWithPool ¶
FlushWithPool 刷新index true => 成功, false => 失败
func TempCreateWithPool ¶
TempCreateWithPool 创建模板
func TempExistWithPool ¶
TempExistWithPool 判断模板是否存在 true => 存在, false => 不存在
Types ¶
type BulkClient ¶
type BulkClient struct {
// contains filtered or unexported fields
}
func NewBulkClient ¶
func NewBulkClient(logger *zap.Logger, client *Client, opt BulkOption) *BulkClient
func (*BulkClient) Add ¶
func (c *BulkClient) Add(indexname, typename, message string) (int, time.Duration)
Add 插入一条记录 返回执行的条目数 + 耗时, 提供给可能的统计模块
func (*BulkClient) Send ¶
func (c *BulkClient) Send() (int, time.Duration)
Send 当调用方推出循环后, 如果缓冲中仍然有数据的, 调用该方法完成发送 返回执行的条目数 + 耗时, 提供给可能的统计模块
func (*BulkClient) Stop ¶
func (c *BulkClient) Stop()
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientWithID ¶
type ClientPool ¶
type ClientPool struct {
// contains filtered or unexported fields
}
var (
Pool *ClientPool
)
func (*ClientPool) Get ¶
func (c *ClientPool) Get() *Client
func (*ClientPool) GetTimeout ¶
func (c *ClientPool) GetTimeout(t time.Duration) (*Client, error)
func (*ClientPool) Put ¶
func (c *ClientPool) Put(client *Client)
type EasyRequest ¶
type EasyRequest struct { Size int64 `json:"size"` PreIndex string `json:"preIndex"` TimePattern string `json:"timePattern"` TimeField string `json:"timeField" default:"@timestamp"` TimeShift int64 `json:"timeShift"` // 本地的偏移时区, 比如UTC就是-8 TimeFrom int64 `json:"timeFrom"` TimeTill int64 `json:"timeTill"` Interval string `json:"interval"` QueryString string `json:"querystring"` Funcs map[string][]string `json:"funcs"` Terms []string `json:"terms"` Filters map[string]any `json:"filters"` Shoulds []map[string]any `json:"shoulds"` MustNot []map[string]any `json:"must_not"` ScriptedMetric *ScriptedMetric `json:"scripted_metric,omitempty"` }
EasyRequest 简易的ES请求结构体, 会自动封装实际的DSL
type HitsResponse ¶
type ScriptedMetric ¶
type ScriptedMetric struct { Toggle bool `json:"toggle,omitempty"` // 定义是否展开script结果集, 默认不展开, 通常只有结果是单层map如 map[string]int 时才有展开需求 Params map[string]any `json:"params,omitempty"` InitScript string `json:"init_script"` MapScript string `json:"map_script"` CombineScript string `json:"combine_script"` ReduceScript string `json:"reduce_script"` }
ScriptedMetric 提供给scripted_metric专用结构体
type SearchRequest ¶
type SearchRequest struct { Indices []string `json:"-"` Size int64 `json:"size"` Query struct { Bool struct { Filter []map[string]any `json:"filter,omitempty"` Must []map[string]any `json:"must,omitempty"` // v0.1版本不提供must MustNot []map[string]any `json:"must_not,omitempty"` Should []map[string]any `json:"should,omitempty"` MinimumShouldMatch int `json:"minimum_should_match,omitempty"` } `json:"bool,omitempty"` } `json:"query,omitempty"` Aggs map[string]map[string]any `json:"aggs,omitempty"` }
SearchRequest 实际的DSL请求结构体
func NewSearchRequest ¶
func NewSearchRequest(in *EasyRequest) (SearchRequest, error)
func (*SearchRequest) Tostring ¶
func (c *SearchRequest) Tostring() string
type SearchResponse ¶
type SearchResponse struct { Timeout bool `json:"timed_out"` Shards struct { Total int `json:"total"` Successful int `json:"successful"` } `json:"_shards"` Status int `json:"status"` Hits struct { Total int64 `json:"total"` Hits []HitsResponse `json:"hits"` } `json:"hits"` Aggs map[string]json.RawMessage `json:"aggregations"` }
SearchResponse ES响应的报文结构体
type SearchResult ¶
type SearchResult struct { Total int64 `json:"total"` Hits []map[string]any `json:"hits"` Aggs []map[string]any `json:"aggs"` }
SearchResult 自动解析后的结构体
func ParseSearchResult ¶
func ParseSearchResult(in []byte, req *EasyRequest) (SearchResult, error)
func SearchWithPool ¶
func SearchWithPool(in EasyRequest) (SearchResult, error)
SearchWithPool 查询数据接口
func (*SearchResult) Tostring ¶
func (c *SearchResult) Tostring() string
Click to show internal directories.
Click to hide internal directories.