aristoteles

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: MIT Imports: 17 Imported by: 12

README

Aristoteles

Common layer for odysseia-greek it holds the elasticsearch interface

Table of contents

Aristoteles - Ἀριστοτέλης

Τριών δει παιδεία: φύσεως, μαθήσεως, ασκήσεως. - Education needs these three: natural endowment, study, practice.

Aristoteles

Installation

Usage

go get github.com/odysseia-greek/aristoteles

Documentation

Index

Constants

View Source
const (
	EnvElasticService  = "ELASTIC_SEARCH_SERVICE"
	EnvElasticUser     = "ELASTIC_SEARCH_USER"
	EnvElasticPassword = "ELASTIC_SEARCH_PASSWORD"
)
View Source
const (
	HOT  = "hot"
	WARM = "warm"
	COLD = "cold"
)

Variables

This section is empty.

Functions

func CreateMockClient

func CreateMockClient(fixtureFiles []string, statusCode int) (*elasticsearch.Client, error)

func ElasticConfig added in v0.1.1

func ElasticConfig(env string, testOverwrite, tls bool) models.Config

func ElasticService added in v0.1.1

func ElasticService(tls bool) string

func GetCert added in v0.1.1

func GetCert(env string, testOverWrite bool) []byte

func HealthCheck added in v0.1.1

func HealthCheck(client Client) error

Types

type Access

type Access interface {
	CreateRole(name string, roleRequest models.CreateRoleRequest) (bool, error)
	CreateUser(name string, userCreation models.CreateUserRequest) (bool, error)
}

type AccessImpl

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

func NewAccessImpl

func NewAccessImpl(suppliedClient *elasticsearch.Client) (*AccessImpl, error)

func (*AccessImpl) CreateRole

func (a *AccessImpl) CreateRole(name string, roleRequest models.CreateRoleRequest) (bool, error)

func (*AccessImpl) CreateUser

func (a *AccessImpl) CreateUser(name string, userCreation models.CreateUserRequest) (bool, error)

type Builder

type Builder interface {
	MatchQuery(term, queryWord string) map[string]interface{}
	MatchAll() map[string]interface{}
	MultipleMatch(mappedFields []map[string]string) map[string]interface{}
	MultiMatchWithGram(queryWord, field string) map[string]interface{}
	MatchPhrasePrefixed(queryWord, field string) map[string]interface{}
	Aggregate(aggregate, field string) map[string]interface{}
	FilteredAggregate(term, queryWord, aggregate, field string) map[string]interface{}
	SearchAsYouTypeIndex(searchWord string) map[string]interface{}
	Index() map[string]interface{}
	TextIndex(policyName string) map[string]interface{}
	DictionaryIndex(min, max int, policyName string) map[string]interface{}
	GrammarIndex(policyName string) map[string]interface{}
	CreateTraceIndexMapping(policyName string) map[string]interface{}
	QuizIndex(policyName string) map[string]interface{}
}

type BuilderImpl

type BuilderImpl struct {
}

func NewBuilderImpl

func NewBuilderImpl() *BuilderImpl

func (*BuilderImpl) Aggregate

func (b *BuilderImpl) Aggregate(aggregate, field string) map[string]interface{}

func (*BuilderImpl) CreateTraceIndexMapping added in v0.4.1

func (b *BuilderImpl) CreateTraceIndexMapping(policyName string) map[string]interface{}

func (*BuilderImpl) DictionaryIndex added in v0.3.3

func (b *BuilderImpl) DictionaryIndex(min, max int, policyName string) map[string]interface{}

func (*BuilderImpl) FilteredAggregate

func (b *BuilderImpl) FilteredAggregate(term, queryWord, aggregate, field string) map[string]interface{}

func (*BuilderImpl) GrammarIndex added in v0.3.3

func (b *BuilderImpl) GrammarIndex(policyName string) map[string]interface{}

func (*BuilderImpl) Index

func (b *BuilderImpl) Index() map[string]interface{}

func (*BuilderImpl) MatchAll

func (b *BuilderImpl) MatchAll() map[string]interface{}

func (*BuilderImpl) MatchPhrasePrefixed added in v0.3.5

func (b *BuilderImpl) MatchPhrasePrefixed(queryWord, field string) map[string]interface{}

func (*BuilderImpl) MatchQuery

func (b *BuilderImpl) MatchQuery(term, queryWord string) map[string]interface{}

func (*BuilderImpl) MultiMatchWithGram

func (b *BuilderImpl) MultiMatchWithGram(queryWord, field string) map[string]interface{}

func (*BuilderImpl) MultipleMatch

func (b *BuilderImpl) MultipleMatch(mappedFields []map[string]string) map[string]interface{}

func (*BuilderImpl) QuizIndex added in v0.3.3

func (b *BuilderImpl) QuizIndex(policyName string) map[string]interface{}

func (*BuilderImpl) SearchAsYouTypeIndex

func (b *BuilderImpl) SearchAsYouTypeIndex(searchWord string) map[string]interface{}

func (*BuilderImpl) TextIndex added in v0.3.3

func (b *BuilderImpl) TextIndex(policyName string) map[string]interface{}

type BulkResponse added in v0.6.0

type BulkResponse struct {
	Errors bool `json:"errors"`
	Items  []struct {
		Index struct {
			ID     string `json:"_id"`
			Result string `json:"result"`
			Status int    `json:"status"`
			Error  struct {
				Type   string `json:"type"`
				Reason string `json:"reason"`
				Cause  struct {
					Type   string `json:"type"`
					Reason string `json:"reason"`
				} `json:"caused_by"`
			} `json:"error"`
		} `json:"index"`
	} `json:"items"`
}

type Client

type Client interface {
	Query() Query
	Document() Document
	Index() Index
	Builder() Builder
	Health() Health
	Access() Access
	Policy() Policy
}

func NewClient

func NewClient(config models.Config) (Client, error)

func NewMockClient

func NewMockClient(fixtureFiles interface{}, statusCode int) (Client, error)

type Document added in v0.1.5

type Document interface {
	Create(index string, body []byte) (*models.CreateResult, error)
	Update(index, id string, body []byte) (*models.CreateResult, error)
	AddItemToDocument(index, id, body, paramName string) (*models.CreateResult, error)
	CreateWithId(index, documentId string, body []byte) (*models.CreateResult, error)
	CreateWithIdAndFirstItem(index, documentId, body, paramName string) (*models.CreateResult, error)
	Bulk(buf bytes.Buffer, index string) (*BulkResponse, error)
}

type DocumentImpl added in v0.1.5

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

func NewDocumentImpl added in v0.1.5

func NewDocumentImpl(suppliedClient *elasticsearch.Client) (*DocumentImpl, error)

func (*DocumentImpl) AddItemToDocument added in v0.4.1

func (d *DocumentImpl) AddItemToDocument(index, id, body, paramName string) (*models.CreateResult, error)

func (*DocumentImpl) Bulk added in v0.6.0

func (d *DocumentImpl) Bulk(buf bytes.Buffer, index string) (*BulkResponse, error)

func (*DocumentImpl) Create added in v0.1.5

func (d *DocumentImpl) Create(index string, body []byte) (*models.CreateResult, error)

func (*DocumentImpl) CreateWithId added in v0.4.1

func (d *DocumentImpl) CreateWithId(index, documentId string, body []byte) (*models.CreateResult, error)

func (*DocumentImpl) CreateWithIdAndFirstItem added in v0.4.1

func (d *DocumentImpl) CreateWithIdAndFirstItem(index, documentId, body, paramName string) (*models.CreateResult, error)

func (*DocumentImpl) Update added in v0.1.5

func (d *DocumentImpl) Update(index, id string, body []byte) (*models.CreateResult, error)

type Elastic

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

func (*Elastic) Access

func (e *Elastic) Access() Access

func (*Elastic) Builder

func (e *Elastic) Builder() Builder

func (*Elastic) Document added in v0.1.5

func (e *Elastic) Document() Document

func (*Elastic) Health

func (e *Elastic) Health() Health

func (*Elastic) Index

func (e *Elastic) Index() Index

func (*Elastic) Policy added in v0.4.3

func (e *Elastic) Policy() Policy

func (*Elastic) Query

func (e *Elastic) Query() Query

type Health

type Health interface {
	Check(ticks, tick time.Duration) bool
	Info() (elasticHealth models.DatabaseHealth)
}

type HealthImpl

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

func NewHealthImpl

func NewHealthImpl(suppliedClient *elasticsearch.Client) (*HealthImpl, error)

func (*HealthImpl) Check

func (h *HealthImpl) Check(ticks, tick time.Duration) bool

func (*HealthImpl) Info

func (h *HealthImpl) Info() (elasticHealth models.DatabaseHealth)

type Index

type Index interface {
	CreateDocument(index string, body []byte) (*models.CreateResult, error)
	Create(index string, request map[string]interface{}) (*models.IndexCreateResult, error)
	CreateWithAlias(indexName string, request map[string]interface{}) (*models.IndexCreateResult, error)
	Delete(index string) (bool, error)
}

type IndexImpl

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

func NewIndexImpl

func NewIndexImpl(suppliedClient *elasticsearch.Client) (*IndexImpl, error)

func (*IndexImpl) Create

func (i *IndexImpl) Create(index string, request map[string]interface{}) (*models.IndexCreateResult, error)

func (*IndexImpl) CreateDocument

func (i *IndexImpl) CreateDocument(index string, body []byte) (*models.CreateResult, error)

func (*IndexImpl) CreateWithAlias added in v0.4.1

func (i *IndexImpl) CreateWithAlias(indexName string, request map[string]interface{}) (*models.IndexCreateResult, error)

func (*IndexImpl) Delete

func (i *IndexImpl) Delete(index string) (bool, error)

func (*IndexImpl) Update added in v0.1.5

func (i *IndexImpl) Update(index string, request map[string]interface{}) (*models.IndexCreateResult, error)

type MockTransport

type MockTransport struct {
	Responses   []*http.Response
	ResponseIdx int
	RoundTripFn func(req *http.Request) (*http.Response, error)
}

func (*MockTransport) RoundTrip

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

type Policy added in v0.4.3

type Policy interface {
	CreatePolicyWithRollOver(name, maxAge, phase string) (*models.IndexCreateResult, error)
	CreateHotPolicy(name string) (*models.IndexCreateResult, error)
	CreateWarmPolicy(name string) (*models.IndexCreateResult, error)
	CreateColdPolicy(name string) (*models.IndexCreateResult, error)
}

type PolicyImpl added in v0.4.3

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

func NewPolicyImpl added in v0.4.3

func NewPolicyImpl(suppliedClient *elasticsearch.Client) (*PolicyImpl, error)

func (*PolicyImpl) CreateColdPolicy added in v0.4.3

func (p *PolicyImpl) CreateColdPolicy(name string) (*models.IndexCreateResult, error)

func (*PolicyImpl) CreateHotPolicy added in v0.4.3

func (p *PolicyImpl) CreateHotPolicy(name string) (*models.IndexCreateResult, error)

func (*PolicyImpl) CreatePolicyWithRollOver added in v0.4.3

func (p *PolicyImpl) CreatePolicyWithRollOver(name, maxAge, phase string) (*models.IndexCreateResult, error)

func (*PolicyImpl) CreateWarmPolicy added in v0.4.3

func (p *PolicyImpl) CreateWarmPolicy(name string) (*models.IndexCreateResult, error)

type Query

type Query interface {
	Match(index string, request map[string]interface{}) (*models.Response, error)
	MatchWithSort(index, mode, sort string, size int, request map[string]interface{}) (*models.Response, error)
	MatchWithScroll(index string, request map[string]interface{}) (*models.Response, error)
	MatchAggregate(index string, request map[string]interface{}) (*models.Aggregations, error)
}

type QueryImpl

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

func NewQueryImpl

func NewQueryImpl(suppliedClient *elasticsearch.Client) (*QueryImpl, error)

func (*QueryImpl) Match

func (q *QueryImpl) Match(index string, request map[string]interface{}) (*models.Response, error)

func (*QueryImpl) MatchAggregate

func (q *QueryImpl) MatchAggregate(index string, request map[string]interface{}) (*models.Aggregations, error)

func (*QueryImpl) MatchWithScroll

func (q *QueryImpl) MatchWithScroll(index string, request map[string]interface{}) (*models.Response, error)

func (*QueryImpl) MatchWithSort

func (q *QueryImpl) MatchWithSort(index, direction, sortField string, size int, request map[string]interface{}) (*models.Response, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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