Documentation ¶
Index ¶
- type Aggregations
- type BulkData
- type ClientProvider
- func (p *ClientProvider) Add(index string, documentID string, body []byte) ([]byte, error)
- func (p *ClientProvider) BackOffGet(index string, query map[string]interface{}, result interface{}, attempts uint, ...) error
- func (p *ClientProvider) Bulk(body []byte) ([]byte, error)
- func (p *ClientProvider) BulkDelete(data []BulkData) ([]byte, error)
- func (p *ClientProvider) BulkInsert(data []BulkData) ([]byte, error)
- func (p *ClientProvider) BulkUpdate(data []BulkData) ([]byte, error)
- func (p *ClientProvider) CheckIfIndexExists(index string) (bool, error)
- func (p *ClientProvider) CheckIfUUIDExists(index, uuidString string) (bool, error)
- func (p *ClientProvider) Count(index string, query map[string]interface{}) (int, error)
- func (p *ClientProvider) CreateDocument(index, documentID string, body []byte) ([]byte, error)
- func (p *ClientProvider) CreateIndex(index string, body []byte) ([]byte, error)
- func (p *ClientProvider) CreateUUID(index string) (string, error)
- func (p *ClientProvider) DelayOfCreateIndex(ex func(str string, b []byte) ([]byte, error), uin uint, du time.Duration, ...) error
- func (p *ClientProvider) DeleteDocumentByQuery(index string, query map[string]interface{}) ([]byte, error)
- func (p *ClientProvider) DeleteIndex(index string, ignoreUnavailable bool) ([]byte, error)
- func (p *ClientProvider) Get(index string, query map[string]interface{}, result interface{}) (err error)
- func (p *ClientProvider) GetIndices(pattern string) ([]string, error)
- func (p *ClientProvider) GetStat(index string, field string, aggType string, ...) (result time.Time, err error)
- func (p *ClientProvider) ReadWithScroll(index string, query map[string]interface{}, result interface{}, ...) (err error)
- func (p *ClientProvider) Search(index string, query map[string]interface{}) ([]byte, error)
- func (p *ClientProvider) SearchWithNoIndex(query map[string]interface{}) ([]byte, error)
- func (p *ClientProvider) UpdateDocument(index string, id string, body interface{}) ([]byte, error)
- func (p *ClientProvider) UpdateDocumentByQuery(index, query, fields string) ([]byte, error)
- func (p *ClientProvider) UpdateFieldByQuery(params Params, ...) (bool, error)
- type Hits
- type NestedHits
- type Params
- type Stat
- type TopHitsStruct
- type Total
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aggregations ¶
type Aggregations struct {
Stat Stat `json:"stat"`
}
Aggregations represents elastic Aggregations result
type ClientProvider ¶
type ClientProvider struct {
// contains filtered or unexported fields
}
ClientProvider ...
func NewClientProvider ¶
func NewClientProvider(params *Params) (*ClientProvider, error)
NewClientProvider ...
func (*ClientProvider) BackOffGet ¶ added in v1.2.3
func (p *ClientProvider) BackOffGet(index string, query map[string]interface{}, result interface{}, attempts uint, delay time.Duration) error
BackOffGet get query result exactly as Get with a backoff delay
func (*ClientProvider) BulkDelete ¶
func (p *ClientProvider) BulkDelete(data []BulkData) ([]byte, error)
BulkDelete deletes more than one item using one request
func (*ClientProvider) BulkInsert ¶
func (p *ClientProvider) BulkInsert(data []BulkData) ([]byte, error)
BulkInsert inserts more than one item using one request
func (*ClientProvider) BulkUpdate ¶
func (p *ClientProvider) BulkUpdate(data []BulkData) ([]byte, error)
BulkUpdate update more than one item using one request
func (*ClientProvider) CheckIfIndexExists ¶
func (p *ClientProvider) CheckIfIndexExists(index string) (bool, error)
CheckIfIndexExists checks if an es index exists and returns a bool depending on whether it exists or not.
func (*ClientProvider) CheckIfUUIDExists ¶
func (p *ClientProvider) CheckIfUUIDExists(index, uuidString string) (bool, error)
CheckIfUUIDExists checks whether a uuid exists as a document id in an index. Returns true or false depending on whether the uuid exists or not
func (*ClientProvider) Count ¶
func (p *ClientProvider) Count(index string, query map[string]interface{}) (int, error)
Count get documents count based on query
func (*ClientProvider) CreateDocument ¶
func (p *ClientProvider) CreateDocument(index, documentID string, body []byte) ([]byte, error)
CreateDocument ...
func (*ClientProvider) CreateIndex ¶
func (p *ClientProvider) CreateIndex(index string, body []byte) ([]byte, error)
CreateIndex ...
func (*ClientProvider) CreateUUID ¶
func (p *ClientProvider) CreateUUID(index string) (string, error)
CreateUUID calls checkIfUUIDExists if a uuid exists in the index then it generates and returns a new one
func (*ClientProvider) DelayOfCreateIndex ¶
func (p *ClientProvider) DelayOfCreateIndex(ex func(str string, b []byte) ([]byte, error), uin uint, du time.Duration, index string, data []byte) error
DelayOfCreateIndex delay creating index and retry if fails
func (*ClientProvider) DeleteDocumentByQuery ¶
func (p *ClientProvider) DeleteDocumentByQuery(index string, query map[string]interface{}) ([]byte, error)
DeleteDocumentByQuery ...
func (*ClientProvider) DeleteIndex ¶
func (p *ClientProvider) DeleteIndex(index string, ignoreUnavailable bool) ([]byte, error)
DeleteIndex removes existing index
func (*ClientProvider) Get ¶
func (p *ClientProvider) Get(index string, query map[string]interface{}, result interface{}) (err error)
Get query result
func (*ClientProvider) GetIndices ¶
func (p *ClientProvider) GetIndices(pattern string) ([]string, error)
GetIndices get all indices based on a specific pattern , or you can use _all to get all indices
func (*ClientProvider) GetStat ¶
func (p *ClientProvider) GetStat(index string, field string, aggType string, mustConditions []map[string]interface{}, mustNotConditions []map[string]interface{}) (result time.Time, err error)
GetStat gets statistics ex. max min, avg
func (*ClientProvider) ReadWithScroll ¶
func (p *ClientProvider) ReadWithScroll(index string, query map[string]interface{}, result interface{}, scrollID string) (err error)
ReadWithScroll scrolls through the pages of size given in the query and adds up the scrollID in the result Which is expected in the subsequent function call to get the next page, empty result indicates the end of the page
func (*ClientProvider) Search ¶
func (p *ClientProvider) Search(index string, query map[string]interface{}) ([]byte, error)
Search ...
func (*ClientProvider) SearchWithNoIndex ¶
func (p *ClientProvider) SearchWithNoIndex(query map[string]interface{}) ([]byte, error)
SearchWithNoIndex for querying across multiple indices for example: GET _search?allow_no_indices=true
func (*ClientProvider) UpdateDocument ¶
func (p *ClientProvider) UpdateDocument(index string, id string, body interface{}) ([]byte, error)
UpdateDocument update elastic single document
func (*ClientProvider) UpdateDocumentByQuery ¶
func (p *ClientProvider) UpdateDocumentByQuery(index, query, fields string) ([]byte, error)
UpdateDocumentByQuery ...
func (*ClientProvider) UpdateFieldByQuery ¶
func (p *ClientProvider) UpdateFieldByQuery(params Params, index, matchFieldName, matchValue, updateFieldName, updateValue string) (bool, error)
UpdateFieldByQuery updates a single field in an es document
params es credentials index es index matchFieldName es field name to match in query eg author_uuid matchValue es field value to match in query eg 97fa918c612a2fda17ba5aa1e1fc933a00e020d7 updateFieldName es field to update eg author_name updateValue es field value to update to eg Rob Underwood
type Hits ¶
type Hits struct { Total Total `json:"total"` MaxScore float32 `json:"max_score"` Hits []*NestedHits `json:"hits"` }
Hits struct
type NestedHits ¶
type NestedHits struct { Index string `json:"_index"` Type string `json:"_type"` ID string `json:"_id"` Score float64 `json:"_score"` Source interface{} `json:"_source"` }
NestedHits struct
type TopHitsStruct ¶
type TopHitsStruct struct { Took int `json:"took"` Hits Hits `json:"hits"` Aggregations Aggregations `json:"aggregations"` }
TopHitsStruct result