Documentation ¶
Index ¶
- Constants
- func NewMapping(mp MappingPayload) string
- type Base
- type Es
- func (es *Es) BulkDelete(ctx context.Context, ids []string) error
- func (es *Es) BulkSaveOrUpdate(ctx context.Context, docs []interface{}) error
- func (es *Es) CheckTypeExists(ctx context.Context) (b bool, err error)
- func (es *Es) ClearIndex(ctx context.Context) error
- func (es *Es) Count(ctx context.Context, paging *Paging) (int64, error)
- func (es *Es) DeleteIndex(ctx context.Context) error
- func (es *Es) GetByID(ctx context.Context, id string) (map[string]interface{}, error)
- func (es *Es) List(ctx context.Context, paging *Paging, ...) ([]interface{}, error)
- func (es *Es) NewIndex(ctx context.Context, mapping string) (exists bool, err error)
- func (es *Es) Page(ctx context.Context, paging *Paging) (PageResult, error)
- func (es *Es) PutMapping(ctx context.Context, mp MappingPayload) error
- func (es *Es) Random(ctx context.Context, paging *Paging) ([]map[string]interface{}, error)
- func (es *Es) SaveOrUpdate(ctx context.Context, doc interface{}) (string, error)
- func (e *Es) SetIndex(index string)
- func (e *Es) SetType(estype string)
- func (es *Es) Stat(ctx context.Context, paging *Paging, aggr interface{}) (map[string]interface{}, error)
- type EsOption
- type Field
- type IBase
- type MappingPayload
- type PageResult
- type Paging
- type QueryCond
- type Sort
Constants ¶
View Source
const ( // SHOULD represents should query SHOULD queryLogic = iota + 1 // MUST represents must query MUST // MUSTNOT represents must_not query MUSTNOT )
View Source
const ( // TERMS represents terms query TERMS queryType = iota + 1 // MATCHPHRASE represents match_phrase query MATCHPHRASE // RANGE represents range query RANGE // PREFIX represents prefix query PREFIX // WILDCARD https://www.elastic.co/guide/en/elasticsearch/reference/6.8/query-dsl-wildcard-query.html WILDCARD // EXISTS https://www.elastic.co/guide/en/elasticsearch/reference/6.8/query-dsl-prefix-query.html EXISTS )
View Source
const ( // TEXT represents text field type TEXT esFieldType = "text" // KEYWORD represents keyword field type KEYWORD esFieldType = "keyword" // DATE represents date field type DATE esFieldType = "date" // LONG represents long field type LONG esFieldType = "long" // INTEGER represents integer field type INTEGER esFieldType = "integer" // SHORT represents short field type SHORT esFieldType = "short" // DOUBLE represents double field type DOUBLE esFieldType = "double" // FLOAT represents float field type FLOAT esFieldType = "float" // BOOL represents bool field type BOOL esFieldType = "boolean" )
Variables ¶
This section is empty.
Functions ¶
func NewMapping ¶
func NewMapping(mp MappingPayload) string
NewMapping return es mapping json string from mp
Types ¶
type Es ¶
type Es struct {
// contains filtered or unexported fields
}
Es defines properties for connecting to an es instance
func (*Es) BulkDelete ¶
BulkDelete delete es docs specified by ids in bulk
func (*Es) BulkSaveOrUpdate ¶
BulkSaveOrUpdate save or update docs in bulk
func (*Es) CheckTypeExists ¶
CheckTypeExists assert the es type exists
func (*Es) ClearIndex ¶
ClearIndex remove all docs
func (*Es) DeleteIndex ¶
DeleteIndex removes the index
func (*Es) List ¶
func (es *Es) List(ctx context.Context, paging *Paging, callback func(message json.RawMessage) (interface{}, error)) ([]interface{}, error)
List fetch docs by paging
func (*Es) PutMapping ¶
func (es *Es) PutMapping(ctx context.Context, mp MappingPayload) error
PutMapping updates mapping
func (*Es) SaveOrUpdate ¶
SaveOrUpdate saves or updates doc
type Field ¶
type Field struct { Name string `json:"name"` Type esFieldType `json:"type"` Format string `json:"format"` }
Field defines a es field
type MappingPayload ¶
MappingPayload defines request payload for es index mapping
type PageResult ¶
type PageResult struct { Page int `json:"page"` // from 1 PageSize int `json:"page_size"` Total int `json:"total"` Docs []interface{} `json:"docs"` HasNextPage bool `json:"has_next_page"` }
PageResult represents result of pagination
type Paging ¶
type Paging struct { StartDate string `json:"startDate"` EndDate string `json:"endDate"` DateField string `json:"dateField"` QueryConds []QueryCond `json:"queryConds"` Skip int `json:"skip"` Limit int `json:"limit"` Sortby []Sort `json:"sortby"` }
Paging defines pagination query conditions
Click to show internal directories.
Click to hide internal directories.