elasticsearch

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API added in v1.8.0

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

API aggregates a client and URL and other common data for accessing the API

func NewElasticSearchAPI added in v1.8.0

func NewElasticSearchAPI(client rchttp.Clienter, elasticSearchAPIURL string, signRequests bool) *API

NewElasticSearchAPI creates an API object

func (*API) CallElastic added in v1.8.0

func (api *API) CallElastic(ctx context.Context, path, method string, payload interface{}) ([]byte, int, error)

CallElastic builds a request to elastic search based on the method, path and payload

func (*API) DeleteSearchIndex added in v1.8.0

func (api *API) DeleteSearchIndex(ctx context.Context, instanceID, dimension string) (int, error)

DeleteSearchIndex removes an index from elasticsearch

func (*API) QuerySearchIndex added in v1.8.0

func (api *API) QuerySearchIndex(ctx context.Context, instanceID, dimension, term string, limit, offset int) (*models.SearchResponse, int, error)

QuerySearchIndex builds query as a json body to call an elasticsearch index with

type Body added in v1.8.0

type Body struct {
	From      int        `json:"from"`
	Size      int        `json:"size"`
	Highlight *Highlight `json:"highlight,omitempty"`
	Query     Query      `json:"query"`
	Sort      []Scores   `json:"sort"`
}

Body represents the request body to elasticsearch

type Bool added in v1.8.0

type Bool struct {
	Must   []Match `json:"must,omitempty"`
	Should []Match `json:"should,omitempty"`
}

Bool represents the desirable goals for query

type Highlight added in v1.8.0

type Highlight struct {
	PreTags  []string          `json:"pre_tags,omitempty"`
	PostTags []string          `json:"post_tags,omitempty"`
	Fields   map[string]Object `json:"fields,omitempty"`
	Order    string            `json:"score,omitempty"`
}

Highlight represents parts of the fields that matched

type Match added in v1.8.0

type Match struct {
	Match map[string]string `json:"match,omitempty"`
}

Match represents the fields that the term should or must match within query

type Object added in v1.8.0

type Object struct{}

Object represents an empty object (as expected by elasticsearch)

type Query added in v1.8.0

type Query struct {
	Bool Bool `json:"bool"`
}

Query represents the request query details

type Score added in v1.8.0

type Score struct {
	Order string `json:"order"`
}

Score contains the ordering of the score (ascending or descending)

type Scores added in v1.8.0

type Scores struct {
	Score Score `json:"_score"`
}

Scores represents a list of scoring, e.g. scoring on relevance, but can add in secondary score such as alphabetical order if relevance is the same for two search results

Jump to

Keyboard shortcuts

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