elasticsearch

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAliasNotFound        = errors.New("alias not found")
	ErrAliasAlreadyCreated  = errors.New("alias is already created")
	ErrIndexNotFound        = errors.New("index not found")
	ErrIndexAlreadyCreated  = errors.New("index already created")
	ErrIndexMappingNotValid = errors.New("parsing error in mapping")
)

Functions

func AliasCreate added in v0.1.8

func AliasCreate(es *elasticsearch.Client, alias, indexName string) error

AliasCreate creates an alias for the given indexName.

When the index does not exist ErrIndexNotExists is returned When the alias is already defined, ErrAliasExist is returned

func AliasDelete added in v0.1.8

func AliasDelete(es *elasticsearch.Client, indexName, alias string) error

AliasDelete removes the alias from the index it is linked to.

When the alias does not it exist it will return a ErrAliasNotExist error.

When the indexName is empty it will search for the indexName using GetAlias().

func AliasGet added in v0.1.8

func AliasGet(es *elasticsearch.Client, alias string) (indexName string, err error)

AliasGet returns the indexName for the given alias.

When the alias is not found an ErrAliasNotFound error is returned.

func AliasUpdate added in v0.1.8

func AliasUpdate(es *elasticsearch.Client, alias, indexName string) (oldIndexName string, err error)

AliasUpdate removes the alias if it exists from another index and creates a new one linked to indexName.

It returns an error when the alias cannot be updated. It returns the old indexName that is removed

func IndexCreate added in v0.1.8

func IndexCreate(es *elasticsearch.Client, alias, mapping string, withAlias bool) (indexName string, err error)

IndexCreate creates a new index with the supplied mapping.

The internal index created from the alias and a timestamp. If 'force' is false, no index is created when the alias exists. When it does not exist a new index is created and the alias is set.

When force is true, there is no check for the alias and no alias is set for created index.

func IndexDelete added in v0.1.8

func IndexDelete(es *elasticsearch.Client, indexName string) error

IndexDelete delete the index from ElasticSearch.

If the error does not exist an ErrIndexNotExist error is returned.

func IndexExists added in v0.1.8

func IndexExists(es *elasticsearch.Client, indexName string) error

func IndexSwitch added in v0.1.8

func IndexSwitch(es *elasticsearch.Client, alias, newIndexName string, deleteOldIndex bool) (oldIndexName string, err error)

IndexSwitch updates the alias with the new index, and deletes the old index.

When you only want to swith the alias use UpdateAlias().

func IsMappingValid added in v0.2.0

func IsMappingValid(es *elasticsearch.Client, indexName string) (bool, error)

func MappingUpdate added in v0.2.0

func MappingUpdate(es *elasticsearch.Client, indexName, esMapping string) error

Types

type ErrorType added in v0.1.8

type ErrorType struct {
	Index       string
	Type        string
	Reason      string
	CauseType   string
	CauseReason string
}

func GetErrorType added in v0.1.8

func GetErrorType(r io.Reader) ErrorType

func (ErrorType) Error added in v0.1.8

func (et ErrorType) Error() error

type Proxy added in v0.1.8

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

func NewProxy added in v0.1.8

func NewProxy(es *elasticsearch.Client) (*Proxy, error)

func (*Proxy) ServeHTTP added in v0.1.8

func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

type QueryBuilder added in v0.1.4

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

func NewQueryBuilder added in v0.1.4

func NewQueryBuilder(defaultFields ...QueryField) *QueryBuilder

func (*QueryBuilder) NewElasticQuery added in v0.1.4

func (qb *QueryBuilder) NewElasticQuery(q *search.QueryTerm) elastic.Query

type QueryField added in v0.1.4

type QueryField struct {
	Field string
	Boost float64
}

type Transport added in v0.1.8

type Transport struct{}

Transport implements the estransport interface with the github.com/valyala/fasthttp HTTP client.

adapted from https://github.com/elastic/go-elasticsearch/blob/master/_examples/fasthttp/fasthttp.go

func (*Transport) RoundTrip added in v0.1.8

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip performs the request and returns a response or error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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