elastic

package
v1.5.32 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 17 Imported by: 4

Documentation

Index

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 BulkData

type BulkData struct {
	IndexName string `json:"index_name"`
	ID        string
	Data      interface{}
}

BulkData to be saved using bulkIndex

type ClientProvider

type ClientProvider struct {
	// contains filtered or unexported fields
}

ClientProvider ...

func NewClientProvider

func NewClientProvider(params *Params) (*ClientProvider, error)

NewClientProvider ...

func (*ClientProvider) Add

func (p *ClientProvider) Add(index string, documentID string, body []byte) ([]byte, error)

Add ...

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) Bulk

func (p *ClientProvider) Bulk(body []byte) ([]byte, error)

Bulk ...

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 Params

type Params struct {
	URL      string
	Username string
	Password string
}

Params ...

type Stat

type Stat struct {
	Value         float64 `json:"value"`
	ValueAsString string  `json:"value_as_string"`
}

Stat represents elastic stat result

type TopHitsStruct

type TopHitsStruct struct {
	Took         int          `json:"took"`
	Hits         Hits         `json:"hits"`
	Aggregations Aggregations `json:"aggregations"`
}

TopHitsStruct result

type Total

type Total struct {
	Value    int    `json:"value"`
	Relation string `json:"relation"`
}

Total struct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL