elasticsearch

package
v0.0.0-...-fdf610b Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2018 License: Apache-2.0 Imports: 10 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructMappingSchema

func ConstructMappingSchema(name string, items map[string]MappingElementTypeName) (piazza.JsonString, error)

ConstructMappingSchema takes a map of parameter names to datatypes and returns the corresponding ES DSL for it.

func IndexExists

func IndexExists(sys *piazza.SystemConfig, index string) (bool, error)

func IsValidArrayTypeMapping

func IsValidArrayTypeMapping(mappingValue interface{}) bool

func IsValidMappingType

func IsValidMappingType(mappingValue interface{}) bool

func PollFunction

func PollFunction(fn GetData) (bool, error)

Types

type DeleteResponse

type DeleteResponse struct {
	Found bool
	ID    string
}

DeleteResponse is the response when a deletion of a document or type occurs

func NewDeleteResponse

func NewDeleteResponse(deleteResponse *elastic.DeleteResponse) *DeleteResponse

NewDeleteResponse is the initializing constructor for DeleteResponse

type GetData

type GetData func() (bool, error)

type GetResult

type GetResult struct {
	ID     string
	Source *json.RawMessage
	Found  bool
}

func NewGetResult

func NewGetResult(getResult *elastic.GetResult) *GetResult

type IIndex

type IIndex interface {
	GetVersion() string

	IndexName() string
	IndexExists() (bool, error)
	TypeExists(typ string) (bool, error)
	ItemExists(typ string, id string) (bool, error)
	Create(settings string) error
	Close() error
	Delete() error
	PostData(typ string, id string, obj interface{}) (*IndexResponse, error)
	PutData(typ string, id string, obj interface{}) (*IndexResponse, error)
	GetByID(typ string, id string) (*GetResult, error)
	DeleteByID(typ string, id string) (*DeleteResponse, error)
	DeleteByIDWait(typ string, id string) (*DeleteResponse, error)
	FilterByMatchAll(typ string, format *piazza.JsonPagination) (*SearchResult, error)
	GetAllElements(typ string) (*SearchResult, error)
	FilterByTermQuery(typ string, name string, value interface{}, format *piazza.JsonPagination) (*SearchResult, error)
	FilterByMatchQuery(typ string, name string, value interface{}, format *piazza.JsonPagination) (*SearchResult, error)
	SearchByJSON(typ string, jsn string) (*SearchResult, error)
	SetMapping(typename string, jsn piazza.JsonString) error
	GetTypes() ([]string, error)
	GetMapping(typ string) (interface{}, error)

	DirectAccess(verb string, endpoint string, input interface{}, output interface{}) error
}

IIndex is an interface to Elasticsearch Index methods

func NewIndexInterface

func NewIndexInterface(sys *piazza.SystemConfig, index string, settings string, mocking bool) (IIndex, error)

NewIndexInterface constructs an IIndex

type Index

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

Index is a representation of the Elasticsearch index.

func NewIndex

func NewIndex(sys *piazza.SystemConfig, index string, settings string) (*Index, error)

NewIndex is the initializing constructor for the type Index.

func NewIndex2

func NewIndex2(url, user, pass, index, settings string) (*Index, error)

func (*Index) Close

func (esi *Index) Close() error

Close the index; if index doesn't already exist, does nothing.

func (*Index) Create

func (esi *Index) Create(settings string) error

Create the index; if index already exists, does nothing.

func (*Index) Delete

func (esi *Index) Delete() error

Delete the index; if index doesn't already exist, does nothing.

func (*Index) DeleteByID

func (esi *Index) DeleteByID(typ string, id string) (*DeleteResponse, error)

DeleteByID deletes a document by ID within a specified index and type.

func (*Index) DeleteByIDWait

func (esi *Index) DeleteByIDWait(typ string, id string) (*DeleteResponse, error)

DeleteByID deletes a document by ID within a specified index and type and waits before returning.

func (*Index) DirectAccess

func (esi *Index) DirectAccess(verb string, endpoint string, input interface{}, output interface{}) error

func (*Index) FilterByMatchAll

func (esi *Index) FilterByMatchAll(typ string, realFormat *piazza.JsonPagination) (*SearchResult, error)

FilterByMatchAll returns all documents of a specified type, in the format specified by the realFormat parameter.

func (*Index) FilterByMatchQuery

func (esi *Index) FilterByMatchQuery(typ string, name string, value interface{}, realFormat *piazza.JsonPagination) (*SearchResult, error)

FilterByMatchQuery creates an Elasticsearch match query and performs the query over the specified type. For more information on match queries, see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html

func (*Index) FilterByTermQuery

func (esi *Index) FilterByTermQuery(typ string, name string, value interface{}, realFormat *piazza.JsonPagination) (*SearchResult, error)

FilterByTermQuery creates an Elasticsearch term query and performs the query over the specified type. For more information on term queries, see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html

func (*Index) GetAllElements

func (esi *Index) GetAllElements(typ string) (*SearchResult, error)

GetAllElements returns all documents of a specified type.

func (*Index) GetByID

func (esi *Index) GetByID(typ string, id string) (*GetResult, error)

GetByID returns a document by ID within the specified index and type.

func (*Index) GetMapping

func (esi *Index) GetMapping(typ string) (interface{}, error)

GetMapping returns the _mapping of a type.

func (*Index) GetTypes

func (esi *Index) GetTypes() ([]string, error)

GetTypes returns the list of types within the index.

func (*Index) GetVersion

func (esi *Index) GetVersion() string

GetVersion returns the Elasticsearch version.

func (*Index) IndexExists

func (esi *Index) IndexExists() (bool, error)

IndexExists checks to see if the index exists.

func (*Index) IndexName

func (esi *Index) IndexName() string

IndexName returns the name of the index.

func (*Index) ItemExists

func (esi *Index) ItemExists(typ string, id string) (bool, error)

ItemExists checks to see if the specified item exists within the type and index specified.

func (*Index) PostData

func (esi *Index) PostData(typ string, id string, obj interface{}) (*IndexResponse, error)

PostData send JSON data to the index.

func (*Index) PutData

func (esi *Index) PutData(typ string, id string, obj interface{}) (*IndexResponse, error)

TODO

func (*Index) SearchByJSON

func (esi *Index) SearchByJSON(typ string, jsn string) (*SearchResult, error)

SearchByJSON performs a search over the index via raw JSON.

func (*Index) SetMapping

func (esi *Index) SetMapping(typename string, jsn piazza.JsonString) error

SetMapping sets the _mapping field for a new type.

func (*Index) TypeExists

func (esi *Index) TypeExists(typ string) (bool, error)

TypeExists checks to see if the specified type exists within the index.

type IndexResponse

type IndexResponse struct {
	Created bool
	ID      string
	Index   string
	Type    string
	Version int
}

func NewIndexResponse

func NewIndexResponse(indexResponse *elastic.IndexResponse) *IndexResponse

type MappingElementTypeName

type MappingElementTypeName string

MappingElementTypeName is just an alias for a string.

const (
	MappingElementTypeText       MappingElementTypeName = "text"
	MappingElementTypeKeyword    MappingElementTypeName = "keyword"
	MappingElementTypeLong       MappingElementTypeName = "long"
	MappingElementTypeInteger    MappingElementTypeName = "integer"
	MappingElementTypeShort      MappingElementTypeName = "short"
	MappingElementTypeByte       MappingElementTypeName = "byte"
	MappingElementTypeDouble     MappingElementTypeName = "double"
	MappingElementTypeFloat      MappingElementTypeName = "float"
	MappingElementTypeDate       MappingElementTypeName = "date"
	MappingElementTypeBool       MappingElementTypeName = "boolean"
	MappingElementTypeBinary     MappingElementTypeName = "binary"
	MappingElementTypeGeoPoint   MappingElementTypeName = "geo_point"
	MappingElementTypeGeoShape   MappingElementTypeName = "geo_shape"
	MappingElementTypeIp         MappingElementTypeName = "ip"
	MappingElementTypeCompletion MappingElementTypeName = "completion"

	MappingElementTypeTextA       MappingElementTypeName = "[text]"
	MappingElementTypeKeywordA    MappingElementTypeName = "[keyword]"
	MappingElementTypeLongA       MappingElementTypeName = "[long]"
	MappingElementTypeIntegerA    MappingElementTypeName = "[integer]"
	MappingElementTypeShortA      MappingElementTypeName = "[short]"
	MappingElementTypeByteA       MappingElementTypeName = "[byte]"
	MappingElementTypeDoubleA     MappingElementTypeName = "[double]"
	MappingElementTypeFloatA      MappingElementTypeName = "[float]"
	MappingElementTypeDateA       MappingElementTypeName = "[date]"
	MappingElementTypeBoolA       MappingElementTypeName = "[boolean]"
	MappingElementTypeBinaryA     MappingElementTypeName = "[binary]"
	MappingElementTypeGeoPointA   MappingElementTypeName = "[geo_point]"
	MappingElementTypeGeoShapeA   MappingElementTypeName = "[geo_shape]"
	MappingElementTypeIpA         MappingElementTypeName = "[ip]"
	MappingElementTypeCompletionA MappingElementTypeName = "[completion]"
)

Constants representing the supported data types for the Event parameters.

type MockIndex

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

func NewMockIndex

func NewMockIndex(indexName string) *MockIndex

func (*MockIndex) Close

func (esi *MockIndex) Close() error

if index doesn't already exist, does nothing

func (*MockIndex) Create

func (esi *MockIndex) Create(settings string) error

if index already exists, does nothing

func (*MockIndex) Delete

func (esi *MockIndex) Delete() error

if index doesn't already exist, does nothing

func (*MockIndex) DeleteByID

func (esi *MockIndex) DeleteByID(typeName string, id string) (*DeleteResponse, error)

func (*MockIndex) DeleteByIDWait

func (esi *MockIndex) DeleteByIDWait(typeName string, id string) (*DeleteResponse, error)

func (*MockIndex) DirectAccess

func (esi *MockIndex) DirectAccess(verb string, endpoint string, input interface{}, output interface{}) error

func (*MockIndex) FilterByMatchAll

func (esi *MockIndex) FilterByMatchAll(typeName string, realFormat *piazza.JsonPagination) (*SearchResult, error)

func (*MockIndex) FilterByMatchQuery

func (esi *MockIndex) FilterByMatchQuery(typ string, name string, value interface{}, realFormat *piazza.JsonPagination) (*SearchResult, error)

func (*MockIndex) FilterByTermQuery

func (esi *MockIndex) FilterByTermQuery(typeName string, name string, value interface{}, realFormat *piazza.JsonPagination) (*SearchResult, error)

func (*MockIndex) GetAllElements

func (esi *MockIndex) GetAllElements(typ string) (*SearchResult, error)

func (*MockIndex) GetByID

func (esi *MockIndex) GetByID(typeName string, id string) (*GetResult, error)

func (*MockIndex) GetMapping

func (esi *MockIndex) GetMapping(typ string) (interface{}, error)

func (*MockIndex) GetTypes

func (esi *MockIndex) GetTypes() ([]string, error)

func (*MockIndex) GetVersion

func (esi *MockIndex) GetVersion() string

func (*MockIndex) IndexExists

func (esi *MockIndex) IndexExists() (bool, error)

func (*MockIndex) IndexName

func (esi *MockIndex) IndexName() string

func (*MockIndex) ItemExists

func (esi *MockIndex) ItemExists(typeName string, id string) (bool, error)

func (*MockIndex) PostData

func (esi *MockIndex) PostData(typeName string, id string, obj interface{}) (*IndexResponse, error)

func (*MockIndex) PutData

func (esi *MockIndex) PutData(typeName string, id string, obj interface{}) (*IndexResponse, error)

TODO

func (*MockIndex) SearchByJSON

func (esi *MockIndex) SearchByJSON(typ string, jsn string) (*SearchResult, error)

func (*MockIndex) SetMapping

func (esi *MockIndex) SetMapping(typeName string, mapping piazza.JsonString) error

func (*MockIndex) TypeExists

func (esi *MockIndex) TypeExists(typ string) (bool, error)

type MockIndexType

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

type QueryFormat

type QueryFormat struct {
	Size  int
	From  int
	Order bool
	Key   string
}

func NewQueryFormat

func NewQueryFormat(params *piazza.JsonPagination) *QueryFormat

NewQueryFormat constructs a QueryFormat

type SearchResult

type SearchResult struct {
	Found bool
	// contains filtered or unexported fields
}

func NewSearchResult

func NewSearchResult(searchResult *elastic.SearchResult) *SearchResult

func (*SearchResult) GetHit

func (r *SearchResult) GetHit(i int) *SearchResultHit

func (*SearchResult) GetHits

func (r *SearchResult) GetHits() *[]*SearchResultHit

func (*SearchResult) NumHits

func (r *SearchResult) NumHits() int

func (*SearchResult) TotalHits

func (r *SearchResult) TotalHits() int64

type SearchResultHit

type SearchResultHit struct {
	ID     string
	Source *json.RawMessage
}

Directories

Path Synopsis
uritemplates
Package uritemplates is a level 4 implementation of RFC 6570 (URI Template, http://tools.ietf.org/html/rfc6570).
Package uritemplates is a level 4 implementation of RFC 6570 (URI Template, http://tools.ietf.org/html/rfc6570).

Jump to

Keyboard shortcuts

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