Documentation
¶
Index ¶
- Constants
- func ElasticError(err error) error
- func NewElasticStore(URI string) (db IDatastore, err error)
- type ElasticStore
- func (dbs *ElasticStore) BulkDelete(factory EntityFactory, entityIDs []string, keys ...string) (int64, error)
- func (dbs *ElasticStore) BulkInsert(entities []Entity) (int64, error)
- func (dbs *ElasticStore) BulkSetFields(factory EntityFactory, field string, values map[string]any, keys ...string) (int64, error)
- func (dbs *ElasticStore) BulkUpdate(entities []Entity) (int64, error)
- func (dbs *ElasticStore) BulkUpsert(entities []Entity) (int64, error)
- func (dbs *ElasticStore) CloneDatastore() (IDatastore, error)
- func (dbs *ElasticStore) Close() error
- func (dbs *ElasticStore) CreateEntityIndex(factory EntityFactory, key string) (string, error)
- func (dbs *ElasticStore) CreateIndex(indexName string) (string, error)
- func (dbs *ElasticStore) Delete(factory EntityFactory, entityID string, keys ...string) error
- func (dbs *ElasticStore) DropIndex(indexName string) (ack bool, err error)
- func (dbs *ElasticStore) ExecuteQuery(source string, query string, args ...any) ([]Json, error)
- func (dbs *ElasticStore) Exists(factory EntityFactory, entityID string, keys ...string) (bool, error)
- func (dbs *ElasticStore) Get(factory EntityFactory, entityID string, keys ...string) (Entity, error)
- func (dbs *ElasticStore) IndexExists(indexName string) bool
- func (dbs *ElasticStore) Insert(entity Entity) (Entity, error)
- func (dbs *ElasticStore) List(factory EntityFactory, entityIDs []string, keys ...string) ([]Entity, error)
- func (dbs *ElasticStore) ListIndices(pattern string) (map[string]int, error)
- func (dbs *ElasticStore) Ping(retries uint, interval uint) error
- func (dbs *ElasticStore) Query(factory EntityFactory) IQuery
- func (dbs *ElasticStore) SetField(factory EntityFactory, entityID string, field string, value any, ...) (err error)
- func (dbs *ElasticStore) SetFields(factory EntityFactory, entityID string, fields map[string]any, keys ...string) (err error)
- func (dbs *ElasticStore) String() string
- func (dbs *ElasticStore) Update(entity Entity) (Entity, error)
- func (dbs *ElasticStore) Upsert(entity Entity) (Entity, error)
Constants ¶
const ( ES_DOC_NOT_FOUND = "not found" AGG_SUM = "sum" AGG_AVG = "avg" AGG_MIN = "min" AGG_MAX = "max" AGG_CNT = "count" )
Variables ¶
This section is empty.
Functions ¶
func ElasticError ¶
ElasticError is wrapper for errors returned by elasticsearch to provide meaningful error
func NewElasticStore ¶
NewElasticStore factory method for elasticsearch data store
Types ¶
type ElasticStore ¶
type ElasticStore struct { URI string // contains filtered or unexported fields }
func (*ElasticStore) BulkDelete ¶
func (dbs *ElasticStore) BulkDelete(factory EntityFactory, entityIDs []string, keys ...string) (int64, error)
BulkDelete delete multiple entities by IDs
func (*ElasticStore) BulkInsert ¶
func (dbs *ElasticStore) BulkInsert(entities []Entity) (int64, error)
BulkInsert inserts multiple entities
func (*ElasticStore) BulkSetFields ¶
func (dbs *ElasticStore) BulkSetFields(factory EntityFactory, field string, values map[string]any, keys ...string) (int64, error)
BulkSetFields Update specific field of multiple entities in a single transaction (eliminates the need to fetch - change - update) The field is the name of the field, values is a map of entityId -> field value
func (*ElasticStore) BulkUpdate ¶
func (dbs *ElasticStore) BulkUpdate(entities []Entity) (int64, error)
BulkUpdate updates multiple entities
func (*ElasticStore) BulkUpsert ¶
func (dbs *ElasticStore) BulkUpsert(entities []Entity) (int64, error)
BulkUpsert update or insert multiple entities
func (*ElasticStore) CloneDatastore ¶
func (dbs *ElasticStore) CloneDatastore() (IDatastore, error)
CloneDatastore Returns a clone (copy) of the instance
func (*ElasticStore) Close ¶
func (dbs *ElasticStore) Close() error
Close Datastore and free resources
func (*ElasticStore) CreateEntityIndex ¶
func (dbs *ElasticStore) CreateEntityIndex(factory EntityFactory, key string) (string, error)
CreateEntityIndex creates an index of entity and add entity field mapping
func (*ElasticStore) CreateIndex ¶
func (dbs *ElasticStore) CreateIndex(indexName string) (string, error)
CreateIndex creates an index (without mapping)
func (*ElasticStore) Delete ¶
func (dbs *ElasticStore) Delete(factory EntityFactory, entityID string, keys ...string) error
Delete entity by id and shard (key)
func (*ElasticStore) DropIndex ¶
func (dbs *ElasticStore) DropIndex(indexName string) (ack bool, err error)
DropIndex drops an index
func (*ElasticStore) ExecuteQuery ¶ added in v1.2.2
func (dbs *ElasticStore) ExecuteQuery(source string, query string, args ...any) ([]Json, error)
ExecuteQuery Execute native KQL query
func (*ElasticStore) Exists ¶
func (dbs *ElasticStore) Exists(factory EntityFactory, entityID string, keys ...string) (bool, error)
Exists checks if entity exists by ID
func (*ElasticStore) Get ¶
func (dbs *ElasticStore) Get(factory EntityFactory, entityID string, keys ...string) (Entity, error)
Get a single entity by ID
func (*ElasticStore) IndexExists ¶
func (dbs *ElasticStore) IndexExists(indexName string) bool
IndexExists tests if index exists
func (*ElasticStore) Insert ¶
func (dbs *ElasticStore) Insert(entity Entity) (Entity, error)
Insert a new entity
func (*ElasticStore) List ¶
func (dbs *ElasticStore) List(factory EntityFactory, entityIDs []string, keys ...string) ([]Entity, error)
List gets multiple entities by IDs
func (*ElasticStore) ListIndices ¶
func (dbs *ElasticStore) ListIndices(pattern string) (map[string]int, error)
ListIndices returns a list of all indices matching the pattern
func (*ElasticStore) Ping ¶
func (dbs *ElasticStore) Ping(retries uint, interval uint) error
Ping tests database connectivity for retries number of time with time interval (in seconds) between retries
func (*ElasticStore) Query ¶
func (dbs *ElasticStore) Query(factory EntityFactory) IQuery
Query is a factory method for query builder Utility
func (*ElasticStore) SetField ¶
func (dbs *ElasticStore) SetField(factory EntityFactory, entityID string, field string, value any, keys ...string) (err error)
SetField update a single field of the document in a single transaction (eliminates the need to fetch - change - update)
func (*ElasticStore) SetFields ¶
func (dbs *ElasticStore) SetFields(factory EntityFactory, entityID string, fields map[string]any, keys ...string) (err error)
SetFields update some fields of the document in a single transaction (eliminates the need to fetch - change - update)
func (*ElasticStore) String ¶
func (dbs *ElasticStore) String() string
String returns the last query DSL
func (*ElasticStore) Update ¶
func (dbs *ElasticStore) Update(entity Entity) (Entity, error)
Update an existing entity only if document exists
func (*ElasticStore) Upsert ¶
func (dbs *ElasticStore) Upsert(entity Entity) (Entity, error)
Upsert update entity or create it if it does not exist