aristoteles

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 17 Imported by: 25

README

Aristoteles

Common layer for odysseia-greek it holds the elasticsearch interface

Installation

Usage

go get github.com/odysseia-greek/agora/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 AddRawFixture added in v0.1.2

func AddRawFixture(name string, data []byte)

func CreateMockClient

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

func ElasticConfig

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

func ElasticService

func ElasticService(tls bool) string

func GetCert

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

func HealthCheck

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

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

func (*BuilderImpl) DictionaryIndex

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

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

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

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

func (*BuilderImpl) SearchAsYouTypeIndex

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

func (*BuilderImpl) TextIndex

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

type BulkResponse

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

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

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

func NewDocumentImpl

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

func (*DocumentImpl) AddItemToDocument

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

func (*DocumentImpl) Bulk

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

func (*DocumentImpl) Create

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

func (*DocumentImpl) CreateWithId

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

func (*DocumentImpl) CreateWithIdAndFirstItem

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

func (*DocumentImpl) Update

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

func (e *Elastic) Document() Document

func (*Elastic) Health

func (e *Elastic) Health() Health

func (*Elastic) Index

func (e *Elastic) Index() Index

func (*Elastic) Policy

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

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

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

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

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

func NewPolicyImpl

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

func (*PolicyImpl) CreateColdPolicy

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

func (*PolicyImpl) CreateHotPolicy

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

func (*PolicyImpl) CreatePolicyWithRollOver

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

func (*PolicyImpl) CreateWarmPolicy

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