Documentation ¶
Index ¶
- Constants
- type BulkDeleteItemV7
- type BulkIndexItemV7
- type BulkUpsertItemV7
- type Config
- type GenericClient
- type MapDataV7
- type Page
- type QueryBody
- type QueryBodyWhere
- type QueryBodyWhereCombo
- func (cmb *QueryBodyWhereCombo) ComboEQ(eq []map[string]interface{}) *QueryBodyWhereCombo
- func (cmb *QueryBodyWhereCombo) ComboIn(in []map[string][]interface{}) *QueryBodyWhereCombo
- func (cmb *QueryBodyWhereCombo) ComboNotEQ(eq []map[string]interface{}) *QueryBodyWhereCombo
- func (cmb *QueryBodyWhereCombo) ComboNotIn(in []map[string][]interface{}) *QueryBodyWhereCombo
- func (cmb *QueryBodyWhereCombo) ComboNotRange(r []map[string]string) *QueryBodyWhereCombo
- func (cmb *QueryBodyWhereCombo) ComboRange(r []map[string]string) *QueryBodyWhereCombo
- func (cmb *QueryBodyWhereCombo) MinAll(min int) *QueryBodyWhereCombo
- func (cmb *QueryBodyWhereCombo) MinEQ(min int) *QueryBodyWhereCombo
- func (cmb *QueryBodyWhereCombo) MinIn(min int) *QueryBodyWhereCombo
- func (cmb *QueryBodyWhereCombo) MinNotEQ(min int) *QueryBodyWhereCombo
- func (cmb *QueryBodyWhereCombo) MinNotIn(min int) *QueryBodyWhereCombo
- func (cmb *QueryBodyWhereCombo) MinNotRange(min int) *QueryBodyWhereCombo
- func (cmb *QueryBodyWhereCombo) MinRange(min int) *QueryBodyWhereCombo
- type QueryBodyWhereLike
- type QueryResult
- type Request
- func (r *Request) Fields(fields ...string) *Request
- func (r *Request) Params() *QueryBody
- func (r *Request) WhereCombo(cmb ...*QueryBodyWhereCombo) *Request
- func (r *Request) WhereEq(field string, eq interface{}) *Request
- func (r *Request) WhereIn(field string, in interface{}) *Request
- func (r *Request) WhereLike(fields, words []string, or bool, level string) *Request
- func (r *Request) WhereNot(typ string, fields ...string) *Request
- func (r *Request) WhereOr(field string, or interface{}) *Request
- func (r *Request) WhereRange(field string, start, end interface{}, scope string) *Request
- type SearchParametersV7
- type UpdateParamsV7
- type UpsertParamsV7
- type WrapErrorLogger
- type WrapInfoLogger
- type WrapTraceLogger
Constants ¶
View Source
const ( // RangeScopeLoRo left open & right open RangeScopeLoRo string = "( )" // RangeScopeLoRc left open & right close RangeScopeLoRc string = "( ]" // RangeScopeLcRo left close & right open RangeScopeLcRo string = "[ )" // RangeScopeLcRc lect close & right close RangeScopeLcRc string = "[ ]" // LikeLevelHigh wildcard keyword LikeLevelHigh string = "high" // LikeLevelMiddle ngram(1,2) LikeLevelMiddle string = "middle" // LikeLevelLow match split word LikeLevelLow string = "low" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BulkDeleteItemV7 ¶
type BulkIndexItemV7 ¶
type BulkUpsertItemV7 ¶
type Config ¶
type Config struct { URL []string // supporting v7. Default to v7 if empty. Version string // optional username to communicate with ElasticSearch Username string // optional password to communicate with ElasticSearch Password string // optional to disable sniff, according to issues on Github, // Sniff could cause issue like "no Elasticsearch node available" DisableSniff bool // Gzip Compress bool // Debug Debug bool // httpClient TransportMaxIdleConns int TransportMaxIdleConnsPerHost int TransportTimeout time.Duration Timeout time.Duration }
Config ...
type GenericClient ¶
type GenericClient interface { CreateIndex(ctx context.Context, index, mapping string) error DeleteIndex(ctx context.Context, index string) error PutMapping(ctx context.Context, index, root, key, valueType string) error Index(ctx context.Context, index, id, bodyJson string) (string, error) Delete(ctx context.Context, index, id string) (string, error) Update(ctx context.Context, index, id string, doc map[string]interface{}, p *UpdateParamsV7) (string, error) BulkIndex(ctx context.Context, bulkData []BulkIndexItemV7) (*elastic.BulkResponse, error) BulkDelete(ctx context.Context, bulkData []BulkDeleteItemV7) (*elastic.BulkResponse, error) BulkUpsert(ctx context.Context, upsertData *UpsertParamsV7) (*elastic.BulkResponse, error) CountByQuery(ctx context.Context, index, query string) (int64, error) Search(ctx context.Context, p *SearchParametersV7) (*elastic.SearchResult, error) SearchWithDSL(ctx context.Context, index, query string) (*elastic.SearchResult, error) QueryBody(sp *QueryBody) *elastic.BoolQuery Client() *elastic.Client }
GenericClient is a generic interface for all versions of ElasticSearch clients
func Build ¶
func Build(name string) (GenericClient, error)
func NewGenericClient ¶
func NewGenericClient(connectConfig *Config) (GenericClient, error)
NewGenericClient create a ES Client
func NewV7Client ¶
func NewV7Client(conf *Config, clientOptFuncs ...elastic.ClientOptionFunc) (GenericClient, error)
returns a new implementation of GenericClient
type QueryBody ¶
type QueryBody struct { Fields []string `json:"fields"` // default:"*" _source,default = * Where QueryBodyWhere `json:"where"` }
QueryBody .
type QueryBodyWhere ¶
type QueryBodyWhere struct { EQ map[string]interface{} `json:"eq"` //可能是数据或字符,[12,333,67] ["asd", "你好"] Or map[string]interface{} `json:"or"` //暂时不支持minimum should In map[string][]interface{} `json:"in"` Range map[string]string `json:"range"` //[10,20) (2018-05-10 00:00:00,2018-05-31 00:00:00] (,30] Like []QueryBodyWhereLike `json:"like"` Combo []*QueryBodyWhereCombo `json:"combo"` //混合与或 Not map[string]map[string]bool `json:"not"` //对eq、in、range条件取反 }
QueryBodyWhere .
type QueryBodyWhereCombo ¶
type QueryBodyWhereCombo struct { EQ []map[string]interface{} `json:"eq"` In []map[string][]interface{} `json:"in"` Range []map[string]string `json:"range"` NotEQ []map[string]interface{} `json:"not_eq"` NotIn []map[string][]interface{} `json:"not_in"` NotRange []map[string]string `json:"not_range"` Min struct { EQ int `json:"eq"` In int `json:"in"` Range int `json:"range"` NotEQ int `json:"not_eq"` NotIn int `json:"not_in"` NotRange int `json:"not_range"` Min int `json:"min"` } `json:"min"` }
QueryBodyWhereCombo .
func (*QueryBodyWhereCombo) ComboEQ ¶
func (cmb *QueryBodyWhereCombo) ComboEQ(eq []map[string]interface{}) *QueryBodyWhereCombo
ComboEQ .
func (*QueryBodyWhereCombo) ComboIn ¶
func (cmb *QueryBodyWhereCombo) ComboIn(in []map[string][]interface{}) *QueryBodyWhereCombo
ComboIn .
func (*QueryBodyWhereCombo) ComboNotEQ ¶
func (cmb *QueryBodyWhereCombo) ComboNotEQ(eq []map[string]interface{}) *QueryBodyWhereCombo
ComboNotEQ .
func (*QueryBodyWhereCombo) ComboNotIn ¶
func (cmb *QueryBodyWhereCombo) ComboNotIn(in []map[string][]interface{}) *QueryBodyWhereCombo
ComboNotIn .
func (*QueryBodyWhereCombo) ComboNotRange ¶
func (cmb *QueryBodyWhereCombo) ComboNotRange(r []map[string]string) *QueryBodyWhereCombo
ComboNotRange .
func (*QueryBodyWhereCombo) ComboRange ¶
func (cmb *QueryBodyWhereCombo) ComboRange(r []map[string]string) *QueryBodyWhereCombo
ComboRange .
func (*QueryBodyWhereCombo) MinAll ¶
func (cmb *QueryBodyWhereCombo) MinAll(min int) *QueryBodyWhereCombo
MinAll .
func (*QueryBodyWhereCombo) MinEQ ¶
func (cmb *QueryBodyWhereCombo) MinEQ(min int) *QueryBodyWhereCombo
MinEQ .
func (*QueryBodyWhereCombo) MinIn ¶
func (cmb *QueryBodyWhereCombo) MinIn(min int) *QueryBodyWhereCombo
MinIn .
func (*QueryBodyWhereCombo) MinNotEQ ¶
func (cmb *QueryBodyWhereCombo) MinNotEQ(min int) *QueryBodyWhereCombo
MinNotEQ .
func (*QueryBodyWhereCombo) MinNotIn ¶
func (cmb *QueryBodyWhereCombo) MinNotIn(min int) *QueryBodyWhereCombo
MinNotIn .
func (*QueryBodyWhereCombo) MinNotRange ¶
func (cmb *QueryBodyWhereCombo) MinNotRange(min int) *QueryBodyWhereCombo
MinNotRange .
func (*QueryBodyWhereCombo) MinRange ¶
func (cmb *QueryBodyWhereCombo) MinRange(min int) *QueryBodyWhereCombo
MinRange .
type QueryBodyWhereLike ¶
type QueryBodyWhereLike struct { KWFields []string `json:"kw_fields"` KW []string `json:"kw"` //将kw的值使用空白间隔给query Or bool `json:"or"` //default:"false" Level string `json:"level"` //默认default }
QueryBodyWhereLike .
type QueryResult ¶
type QueryResult struct { Order string `json:"order"` Sort string `json:"sort"` Result json.RawMessage `json:"result"` Page *Page `json:"page"` }
QueryResult query result.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request request to elastic
func (*Request) WhereCombo ¶
func (r *Request) WhereCombo(cmb ...*QueryBodyWhereCombo) *Request
WhereCombo where combo
type SearchParametersV7 ¶
type SearchParametersV7 struct { Index string Query elastic.Query From int PageSize int Sorter []elastic.Sorter Aggregation []map[string]elastic.Aggregation SearchAfter []interface{} }
SearchParametersV7 holds all required and optional parameters for executing a search
type UpdateParamsV7 ¶
type UpsertParamsV7 ¶
type UpsertParamsV7 struct { Insert bool RetryOnConflict int UpsertBody []BulkUpsertItemV7 }
type WrapErrorLogger ¶
type WrapErrorLogger struct{}
func (WrapErrorLogger) Printf ¶
func (logger WrapErrorLogger) Printf(format string, vars ...interface{})
type WrapInfoLogger ¶
type WrapInfoLogger struct{}
func (WrapInfoLogger) Printf ¶
func (logger WrapInfoLogger) Printf(format string, vars ...interface{})
type WrapTraceLogger ¶
type WrapTraceLogger struct{}
func (WrapTraceLogger) Printf ¶
func (logger WrapTraceLogger) Printf(format string, vars ...interface{})
Click to show internal directories.
Click to hide internal directories.