es

package
v0.0.0-...-8b292c0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

********************************************************************************** The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **********************************************************************************

********************************************************************************** The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **********************************************************************************

********************************************************************************** The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **********************************************************************************

********************************************************************************** The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **********************************************************************************

********************************************************************************** The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **********************************************************************************

Index

Constants

This section is empty.

Variables

View Source
var (
	// InvalidQueryResultType is an Elasticsearch Dataaccess error code  that
	// represents an unsupported QueryResultType value was used
	InvalidQueryResultType = 701
	// ErrInvalidQueryResultType is the error representation when an invalid query
	// result type has been used
	ErrInvalidQueryResultType = fmt.Errorf("[%d] invalid or unsupported query result type", InvalidQueryResultType)
)

Functions

This section is empty.

Types

type AcknowledgedBody

type AcknowledgedBody struct {
	Index              string `json:"index" mapstructure:"index"`
	Acknowledged       bool   `json:"acknowledged" mapstructure:"acknowledged"`
	ShardsAcknowledged bool   `json:"shards_acknowledged" mapstructure:"shards_acknowledged"`
}

AcknowledgedBody is the object representation of an Acknoledgmenet from the Elasticsearch API

type CountResponseBody

type CountResponseBody struct {
	Shards interface{} `json:"_shards" mapstructure:"_shards"`
	Count  int         `json:"count" mapstructure:"count"`
}

CountResponseBody is the object representation of the ES Count API response

type Document

type Document struct {
	Source     map[string]interface{} `json:"_source" mapstructure:"_source"`
	Index      string                 `json:"_index" mapstructure:"_index"`
	Type       string                 `json:"_type" mapstructure:"_type"`
	DocumentID string                 `json:"_id" mapstructure:"_id"`
	Score      float64                `json:"_score" mapstructure:"_score"`
}

Document is the object representation of the documents returned from an Elasticsearch query

type Elasticsearch

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

Elasticsearch is a struct that represents (and is a proxy for) an ElasticSearch cluster This object is a wrapper around the github.com/elastic/go-elasticsearch/v8 library and implements the DataSource interface

func NewElasticsearch

func NewElasticsearch(dsConfig dataaccess.DataSourceConfiguration) (*Elasticsearch, error)

NewElasticsearch creates and returns a pointer to a new ElasticSearch instance and configures the instance using config and sets up a request channel using requestChannel

func (*Elasticsearch) Client

func (elasticsearch *Elasticsearch) Client() *elastic.Client

SetUnmarshalFn sets the object specific logic to unmarshal the Elasticsearch objects to their respective object respresentation

type ElasticsearchIndexConfiguration

type ElasticsearchIndexConfiguration struct {
	IndexCreateConfig ElasticsearchIndexCreateConfiguration `json:"indexcreateconfig" yaml:"indexcreateconfig" mapstructure:"indexcreateconfig"`
	Mappings          map[string]interface{}                `json:"mappings" yaml:"mappings" mapstructure:"mappings"`
	Name              string                                `json:"name" yaml:"name" mapstructure:"name"`
	Create            bool                                  `json:"create" yaml:"create" mapstructure:"create"`
}

ElasticsearchIndexConfiguration holds all of the information need to define an index and provides the optional configuration parameters if the index does not exist

type ElasticsearchIndexCreateConfiguration

type ElasticsearchIndexCreateConfiguration struct {
	ShardCount   int `json:"number_of_shards" yaml:"number_of_shards" mapstructure:"number_of_shards"`
	ReplicaCount int `json:"number_of_replicas" yaml:"number_of_replicas" mapstructure:"number_of_replicas"`
}

ElasticsearchIndexCreateConfiguration holds all of the configuration information for creating an elastic search index

type ErrorResponseBody

type ErrorResponseBody struct {
	Error  ResponseError `json:"error" mapstructure:"error"`
	Status int           `json:"status" mapstructure:"status"`
}

ErrorResponseBody is object representation of an error returned from Elasticsearch API

type QueryDocumentsResponseBody

type QueryDocumentsResponseBody struct {
	Hits     QueryHits `json:"hits" mapstructure:"hits"`
	Shards   Shards    `json:"_shards" mapstructure:"_shards"`
	Took     int       `json:"took" mapstructure:"took"`
	TimedOut bool      `json:"timed_out" mapstructure:"timed_out"`
}

QueryDocumentsResponseBody is the object representation of an Elasticsearch query response containing multpiple documents

type QueryHits

type QueryHits struct {
	Documents []Document     `json:"hits" mapstructure:"hits"`
	Total     QueryHitsTotal `json:"total" mapstructure:"total"`
	MaxScore  float64        `json:"max_score" mapstructure:"max_score"`
}

QueryHits is the object that represents the statistics of the documents found by the query and the collection of the documents themselves

type QueryHitsTotal

type QueryHitsTotal struct {
	Value    int    `json:"value" mapstructure:"value"`
	Relation string `json:"relation" mapstructure:"relation"`
}

QueryHitsTotal is the object representation of the relevant statistics around the return from a query

type QueryResultType

type QueryResultType int

QueryResultType represents an enum type for the different values for the result of a query

const (
	// CREATED represents an item has been add/created result
	CREATED QueryResultType = iota
	// UPDATED represents an item updated result
	UPDATED
)

func QueryResultTypeFromString

func QueryResultTypeFromString(queryResultTypeString string) (returnResultType QueryResultType, err error)

QueryResultTypeFromString returns the QueryResultType from a string representation

func (QueryResultType) String

func (queryResultType QueryResultType) String() string

String returns the string representation of a QueryResultType

type ResponseError

type ResponseError struct {
	RootCause []ResponseErrorCause `json:"root_cause" mapstructure:"root_cause"`
	CausedBy  ResponseErrorCause   `json:"caused_by" mapstructure:"caused_by"`
	Type      string               `json:"type" maspstructure:"type"`
	Reason    string               `json:"reason" mapstructure:"reason"`
}

ResponseError is the top level error object returned in an API Error response

type ResponseErrorCause

type ResponseErrorCause struct {
	Type   string `json:"type" mapstructure:"type"`
	Reason string `json:"reason" mapstructure:"reason"`
}

ResponseErrorCause represents the cause for an error returned in an API error response

type SaveItemResponseBody

type SaveItemResponseBody struct {
	Shards        interface{}     `json:"_shards" mapstructure:"_shards"`
	Index         string          `json:"_index" mapstructure:"_index"`
	DocumentType  string          `json:"_type" mapstructure:"_type"`
	DocumentID    string          `json:"_id" mapstructure:"_id"`
	Version       float64         `json:"_version" mapstructure:"_version"`
	Result        QueryResultType `json:"result" mapstructure:"result"`
	SequenceNum   int             `json:"_seq_no" mapstructure:"_seq_no"`
	PrimaryTerm   int             `json:"_primary_term" mapstructure:"_primary_term"`
	ForcedRefresh bool            `json:"forced_refresh" mapstructure:"forced_refresh"`
}

SaveItemResponseBody is the object representation of the ES Save API response

func (SaveItemResponseBody) MarshalJSON

func (saveItemResponseBody SaveItemResponseBody) MarshalJSON() ([]byte, error)

MarshalJSON allows custom serialization of the SaveItemResponseBody by serializing the following values:

Result -> to a string representation

func (*SaveItemResponseBody) UnmarshalJSON

func (saveItemResponseBody *SaveItemResponseBody) UnmarshalJSON(data []byte) error

UnmarshalJSON allows custom deserializtion of the SaveItemResponseBody by de- serilaizing the following values:

Result -> enum of type QueryResultType

type Shards

type Shards struct {
	Total      int `json:"total" mapstructure:"total"`
	Successful int `json:"successful" mapstructure:"successful"`
	Skipped    int `json:"skipped" mapstructure:"skipped"`
	Failed     int `json:"failed" mapstructure:"failed"`
}

Shards is the object represntation for the shard status during an API call

Jump to

Keyboard shortcuts

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