Documentation
¶
Index ¶
- Constants
- func FieldAnalyzer(fieldName, val string) *elastic.MatchPhraseQuery
- func FieldArray(fieldName string) *elastic.SliceQuery
- func FieldEq(fieldName string, val interface{}) *elastic.TermQuery
- func FieldIN(fieldName string, val ...interface{}) *elastic.TermsQuery
- func FieldLike(fieldName, val string) *elastic.FuzzyQuery
- func FieldNotNull(fieldName string) *elastic.ExistsQuery
- func FieldRange(fieldName string) *elastic.RangeQuery
- func FieldStartWith(fieldName, subString string) *elastic.PrefixQuery
- func FieldTopID(query Query, ids ...string) *elastic.PinnedQuery
- func Float64ToString(val interface{}) string
- func IkMaxWord() string
- func IkSmart() string
- type EQueryReq
- func (e *EQueryReq) SetAggregation(aliseName string, fieldName string) *EQueryReq
- func (e *EQueryReq) SetAggregationOpt(aliseName string, aggregation elastic.Aggregation) *EQueryReq
- func (e *EQueryReq) SetCollapseField(collapseField string) *EQueryReq
- func (e *EQueryReq) SetExcludesSource(excludes ...string) *EQueryReq
- func (e *EQueryReq) SetFetchSource(fetchSource bool) *EQueryReq
- func (e *EQueryReq) SetIncludesSource(includes ...string) *EQueryReq
- func (e *EQueryReq) SetPage(pageNo, pageSize int) *EQueryReq
- func (e *EQueryReq) SetSort(sortField ...elastic.Sorter) *EQueryReq
- func (e *EQueryReq) Source() (interface{}, error)
- type Eelastic
- func (e *Eelastic) Client() *elastic.Client
- func (e *Eelastic) Count(ctx context.Context, indexName ...string) (int64, error)
- func (e *Eelastic) DelIndexAlias(ctx context.Context, index, AliasName string) (bool, error)
- func (e *Eelastic) DelItemByID(ctx context.Context, index string, id string) (isDel bool, err error)
- func (e *Eelastic) DelItemByIDs(ctx context.Context, index string, ids ...interface{}) (count int64, err error)
- func (e *Eelastic) DelTable(ctx context.Context, index string) (isok bool, err error)
- func (e *Eelastic) GetIndexDetail(ctx context.Context, index ...string) (map[string]interface{}, error)
- func (e *Eelastic) GetItemByID(index string, id interface{}) (rep *elastic.GetResult, err error)
- func (e *Eelastic) InitTable(ctx context.Context, index string, mappings interface{}) (bool, error)
- func (e *Eelastic) MultiSearch(ctx context.Context, req MultiQueryReq) (*elastic.MultiSearchResult, error)
- func (e *Eelastic) QueryAggregations(ctx context.Context, query *EQueryReq) (*elastic.SearchResult, error)
- func (e *Eelastic) QuerySql(ctx context.Context, sql string, result interface{}) (total int64, err error)
- func (e *Eelastic) Search(ctx context.Context, query *EQueryReq) (*elastic.SearchResult, error)
- func (e *Eelastic) SetIndexAlias(ctx context.Context, index, AliasName string) (bool, error)
- func (e *Eelastic) UpsertAll(ctx context.Context, index string, values map[string]interface{}) (int64, error)
- func (e *Eelastic) UpsertOne(ctx context.Context, index string, id string, value interface{}) (isok bool, err error)
- type Eq
- type Field
- func (f *Field) NoCondition() bool
- func (f *Field) SetEq(val interface{}) *Field
- func (f *Field) SetGt(val interface{}) *Field
- func (f *Field) SetGte(val interface{}) *Field
- func (f *Field) SetIn(vals []interface{}) *Field
- func (f *Field) SetLt(val interface{}) *Field
- func (f *Field) SetLte(val interface{}) *Field
- type Geo
- type Gt
- type Gte
- type In
- type IndexOptions
- type Lt
- type Lte
- type Mapping
- type MultiQueryReq
- type Query
- type QueryCondition
- type Row
- func (f *Row) CanDocValues(can bool) *Row
- func (f *Row) CanIndex(can bool) *Row
- func (f *Row) CanStore(can bool) *Row
- func (f *Row) SetAnalyzer(a string) *Row
- func (f *Row) SetFormat(fmat string) *Row
- func (f *Row) SetRows(t string) *Row
- func (f *Row) SetSearchAnalyzer(s string) *Row
- func (f *Row) SetType(t string) *Row
- type Rows
- type Sort
- type Value
Constants ¶
View Source
const ( AggregationSize = 1000 CollapseSize = 1000 )
size
View Source
const ( SortAsc = "ASC" SortDesc = "DESC" )
sort
View Source
const ( ActionAnd = 1 ActionOr = 2 ActionNot = 3 )
View Source
const ( CreateSucc = "created" UpdateSucc = "updated" DeleteSucc = "deleted" Noop = "noop" DefaultLimit = "1000" )
View Source
const ( DefaultNum = 0 // type Type = _type(DefaultNum) // dynamic type Dynamic = _dynamic(DefaultNum) //index type Index = _index(DefaultNum) // yyyy-MM-dd HH:mm:ss DateTimeFormat = "yyyy-MM-dd HH:mm:ss" // yyyy-MM-dd DateFormat = "yyyy-MM-dd" //HH:mm:ss TimeFormat = "HH:mm:ss" BoolTrue = true BoolFalse = false )
版本7.x
Variables ¶
This section is empty.
Functions ¶
func FieldAnalyzer ¶
func FieldAnalyzer(fieldName, val string) *elastic.MatchPhraseQuery
text type to Analyzer
func FieldNotNull ¶
func FieldNotNull(fieldName string) *elastic.ExistsQuery
func FieldRange ¶
func FieldRange(fieldName string) *elastic.RangeQuery
func FieldStartWith ¶
func FieldStartWith(fieldName, subString string) *elastic.PrefixQuery
func Float64ToString ¶
func Float64ToString(val interface{}) string
Types ¶
type EQueryReq ¶
func BuildEQueryReq ¶
func BuildEQueryReq(q *QueryCondition) *EQueryReq
func NewEQueryReq ¶
func (*EQueryReq) SetAggregation ¶
func (*EQueryReq) SetAggregationOpt ¶
func (*EQueryReq) SetCollapseField ¶
func (*EQueryReq) SetExcludesSource ¶
func (*EQueryReq) SetFetchSource ¶
fetchSource = true ==>need show fields
func (*EQueryReq) SetIncludesSource ¶
type Eelastic ¶
type Eelastic struct {
// contains filtered or unexported fields
}
func (*Eelastic) DelIndexAlias ¶
func (*Eelastic) DelItemByID ¶
func (e *Eelastic) DelItemByID(ctx context.Context, index string, id string) (isDel bool, err error)
删除数据
func (*Eelastic) DelItemByIDs ¶
func (e *Eelastic) DelItemByIDs(ctx context.Context, index string, ids ...interface{}) (count int64, err error)
ids can int or string
func (*Eelastic) GetIndexDetail ¶
func (*Eelastic) GetItemByID ¶
get data
func (*Eelastic) MultiSearch ¶
func (e *Eelastic) MultiSearch(ctx context.Context, req MultiQueryReq) (*elastic.MultiSearchResult, error)
if version =8.* some version can not use it to search
func (*Eelastic) QueryAggregations ¶
func (*Eelastic) QuerySql ¶
func (e *Eelastic) QuerySql(ctx context.Context, sql string, result interface{}) (total int64, err error)
between 支持数字类型,支持指定字段查询
func (*Eelastic) SetIndexAlias ¶
type Field ¶
type Field struct { Action int32 `json:"action"` Name string `json:"name"` Alise string `json:"alise"` Value Value `json:"value"` }
func NewQFieldAnd ¶
func NewQFieldNot ¶
func NewQFieldOr ¶
func (*Field) NoCondition ¶
type IndexOptions ¶
type IndexOptions int
func (IndexOptions) Docs ¶
func (o IndexOptions) Docs() string
func (IndexOptions) Freqs ¶
func (o IndexOptions) Freqs() string
func (IndexOptions) Offsets ¶
func (o IndexOptions) Offsets() string
func (IndexOptions) Positions ¶
func (o IndexOptions) Positions() string
type Mapping ¶
type Mapping struct { Dynamic string `json:"dynamic,omitempty"` //default true Rows map[string]Row `json:"properties"` }
func NewMapping ¶
func NewMapping() *Mapping
func (*Mapping) Mappings ¶
func (m *Mapping) Mappings() interface{}
Mappings return mappings interface{}
func (*Mapping) SetDynamic ¶
type MultiQueryReq ¶
Mult Query
func NewMultiQueryReq ¶
func NewMultiQueryReq(index string) *MultiQueryReq
func (*MultiQueryReq) Add ¶
func (m *MultiQueryReq) Add(req ...*EQueryReq) *MultiQueryReq
type QueryCondition ¶
type QueryCondition struct { Index []string `json:"index"` Fields []*Field `json:"fields"` Sort []Sort `json:"sort"` Page int `json:"page"` PageSize int `json:"pageSize"` Source []string `json:"source"` //only return this fields,default all }
func NewQueryCondition ¶
func NewQueryCondition(index ...string) *QueryCondition
func (*QueryCondition) AddField ¶
func (q *QueryCondition) AddField(field ...*Field)
func (*QueryCondition) SetPage ¶
func (q *QueryCondition) SetPage(pageNo, pageSize int)
type Row ¶
type Row struct { Type string `json:"type"` Index *bool `json:"index,omitempty"` //default true,支持搜索,旧版本使用:"not_analyzed" Store *bool `json:"store,omitempty"` //default false ,need not set Format string `json:"format,omitempty"` //时间类型格式化 Analyzer string `json:"analyzer,omitempty"` //写入时就进行分词,最大拆分=ik_max_word,粗略拆分=ik_smart //text使用 SearchAnalyzer string `json:"search_analyzer,omitempty"` //搜索阶段进行分词,会覆盖上面的属性 ,"search_analyzer": "ik_smart" //text使用 Rows *map[string]Rows `json:"fields,omitempty"` //复合 字段,用于text 的全文搜索,如 type = keyword DocValues *bool `json:"doc_values,omitempty"` //default true ,need not set }
func (*Row) CanDocValues ¶
type = keyword,boolean,binary,date,number
func (*Row) SetSearchAnalyzer ¶
type = text ,一般 会主动选择设置此参数
type Value ¶
type Value struct { Vals []interface{} Eq *Eq `json:"eq,omitempty"` //Vals first one In *In `json:"in,omitempty"` Gt *Gt `json:"gt,omitempty"` //Vals first one Gte *Gte `json:"gte,omitempty"` //Vals first one Lt *Lt `json:"lt,omitempty"` //Vals first one Lte *Lte `json:"lte,omitempty"` //Vals first one }
Click to show internal directories.
Click to hide internal directories.