elasticutils

package
v0.0.0-...-0e8dd81 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2019 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(client *elastic.Client, index string, tp string, query elastic.Query) (int64, error)

Count counts all objects subject to a query

func CreateBulk

func CreateBulk(client *elastic.Client, index string, tp string, objects chan interface{}) (err error)

CreateBulk creates a lazily computed set of objects in bulk

func CreateIndex

func CreateIndex(client *elastic.Client, index string, mapping interface{}) (created bool, err error)

CreateIndex creates an index unless it already exists

func DeleteBulk

func DeleteBulk(client *elastic.Client, index string, tp string, query elastic.Query) (err error)

DeleteBulk deletes objects subject to a given query

func FetchObjects

func FetchObjects(client *elastic.Client, index string, tp string, query elastic.Query) <-chan *Object

FetchObjects fetches objects subject to an exact query

func FlushIndex

func FlushIndex(client *elastic.Client, indices ...string) (err error)

FlushIndex flushes an index

func RefreshIndex

func RefreshIndex(client *elastic.Client, indices ...string) (err error)

RefreshIndex refreshes an index

func UpdateAll

func UpdateAll(client *elastic.Client, index string, tp string, script *elastic.Script) (err error)

UpdateAll updates all objects inside a given index

Types

type HitInfo

type HitInfo struct {
	Highlight *elastic.SearchHitHighlight
	Score     *float64
}

HitInfo represents information about this object as a hit

type Object

type Object struct {
	Source *json.RawMessage // the source of this object (if any)
	Hit    *HitInfo         // information about this object as a result (if available)
	// contains filtered or unexported fields
}

Object represents an object within elasticsearch

func FetchObject

func FetchObject(client *elastic.Client, index string, tp string, query elastic.Query, highlight *elastic.Highlight) (obj *Object, took *time.Duration, err error)

FetchObject fetches a single object from the database or returns nil

func FetchOrCreateObject

func FetchOrCreateObject(client *elastic.Client, index string, tp string, query elastic.Query, Data interface{}) (obj *Object, created bool, err error)

FetchOrCreateObject fetches the object returned from the query, or creates a new one if no result is retrieved

func NewObjectFromFields

func NewObjectFromFields(client *elastic.Client, index string, tp string, Data interface{}) (obj *Object, err error)

NewObjectFromFields creates a new ec object on the server

func NewObjectFromHit

func NewObjectFromHit(client *elastic.Client, hit *elastic.SearchHit) (obj *Object, err error)

NewObjectFromHit creates a new object using a SearchHit

func NewObjectFromID

func NewObjectFromID(client *elastic.Client, index string, tp string, id string) (obj *Object, err error)

NewObjectFromID fetches a new EC object from the server

func (*Object) Delete

func (obj *Object) Delete() (err error)

Delete deletes this object

func (*Object) GetID

func (obj *Object) GetID() string

GetID gets the id of this object

func (*Object) Index

func (obj *Object) Index() (err error)

Index indexes this object in the database

func (*Object) IsIndexed

func (obj *Object) IsIndexed() bool

IsIndexed checks if an object is still indexed

func (*Object) Pack

func (obj *Object) Pack(v interface{}) (err error)

Pack will re-marshal an object from json

func (*Object) Reload

func (obj *Object) Reload() (err error)

Reload reloads this object from the database

func (*Object) Save

func (obj *Object) Save() (err error)

Save saves this object into the database

func (*Object) Unpack

func (obj *Object) Unpack(v interface{}) (err error)

Unpack will unpack this object as json

func (*Object) UnpackFields

func (obj *Object) UnpackFields() (fields map[string]interface{}, err error)

UnpackFields unpacks this object into a set of fields

type ResultsPage

type ResultsPage struct {
	Hits  []*Object
	Total int64

	Took time.Duration

	From int64
	Size int64
}

ResultsPage represents a single page of results

func FetchObjectsPage

func FetchObjectsPage(client *elastic.Client, index string, tp string, query elastic.Query, highlight *elastic.Highlight, from int64, size int64) (page *ResultsPage, err error)

FetchObjectsPage fetches a set of objects given a specific slicing

Jump to

Keyboard shortcuts

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