pz-gocommon: github.com/venicegeo/pz-gocommon/elasticsearch Index | Files | Directories

package elasticsearch

import "github.com/venicegeo/pz-gocommon/elasticsearch"

Index

Package Files

common.go index.go mock_index.go responses.go

func ConstructMappingSchema Uses

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 Uses

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

func IsValidArrayTypeMapping Uses

func IsValidArrayTypeMapping(mappingValue interface{}) bool

func IsValidMappingType Uses

func IsValidMappingType(mappingValue interface{}) bool

func PollFunction Uses

func PollFunction(fn GetData) (bool, error)

type DeleteResponse Uses

type DeleteResponse struct {
    Found bool
    ID    string
}

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

func NewDeleteResponse Uses

func NewDeleteResponse(deleteResponse *elastic.DeleteResponse) *DeleteResponse

NewDeleteResponse is the initializing constructor for DeleteResponse

type GetData Uses

type GetData func() (bool, error)

type GetResult Uses

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

func NewGetResult Uses

func NewGetResult(getResult *elastic.GetResult) *GetResult

type IIndex Uses

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 Uses

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

NewIndexInterface constructs an IIndex

type Index Uses

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

Index is a representation of the Elasticsearch index.

func NewIndex Uses

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

NewIndex is the initializing constructor for the type Index.

func NewIndex2 Uses

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

func (*Index) Close Uses

func (esi *Index) Close() error

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

func (*Index) Create Uses

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

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

func (*Index) Delete Uses

func (esi *Index) Delete() error

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

func (*Index) DeleteByID Uses

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 Uses

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 Uses

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

func (*Index) FilterByMatchAll Uses

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 Uses

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 Uses

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 Uses

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

GetAllElements returns all documents of a specified type.

func (*Index) GetByID Uses

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 Uses

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

GetMapping returns the _mapping of a type.

func (*Index) GetTypes Uses

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

GetTypes returns the list of types within the index.

func (*Index) GetVersion Uses

func (esi *Index) GetVersion() string

GetVersion returns the Elasticsearch version.

func (*Index) IndexExists Uses

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

IndexExists checks to see if the index exists.

func (*Index) IndexName Uses

func (esi *Index) IndexName() string

IndexName returns the name of the index.

func (*Index) ItemExists Uses

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 Uses

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

PostData send JSON data to the index.

func (*Index) PutData Uses

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

TODO

func (*Index) SearchByJSON Uses

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

SearchByJSON performs a search over the index via raw JSON.

func (*Index) SetMapping Uses

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

SetMapping sets the _mapping field for a new type.

func (*Index) TypeExists Uses

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

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

type IndexResponse Uses

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

func NewIndexResponse Uses

func NewIndexResponse(indexResponse *elastic.IndexResponse) *IndexResponse

type MappingElementTypeName Uses

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 Uses

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

func NewMockIndex Uses

func NewMockIndex(indexName string) *MockIndex

func (*MockIndex) Close Uses

func (esi *MockIndex) Close() error

if index doesn't already exist, does nothing

func (*MockIndex) Create Uses

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

if index already exists, does nothing

func (*MockIndex) Delete Uses

func (esi *MockIndex) Delete() error

if index doesn't already exist, does nothing

func (*MockIndex) DeleteByID Uses

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

func (*MockIndex) DeleteByIDWait Uses

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

func (*MockIndex) DirectAccess Uses

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

func (*MockIndex) FilterByMatchAll Uses

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

func (*MockIndex) FilterByMatchQuery Uses

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

func (*MockIndex) FilterByTermQuery Uses

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

func (*MockIndex) GetAllElements Uses

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

func (*MockIndex) GetByID Uses

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

func (*MockIndex) GetMapping Uses

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

func (*MockIndex) GetTypes Uses

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

func (*MockIndex) GetVersion Uses

func (esi *MockIndex) GetVersion() string

func (*MockIndex) IndexExists Uses

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

func (*MockIndex) IndexName Uses

func (esi *MockIndex) IndexName() string

func (*MockIndex) ItemExists Uses

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

func (*MockIndex) PostData Uses

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

func (*MockIndex) PutData Uses

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

TODO

func (*MockIndex) SearchByJSON Uses

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

func (*MockIndex) SetMapping Uses

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

func (*MockIndex) TypeExists Uses

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

type MockIndexType Uses

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

type QueryFormat Uses

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

func NewQueryFormat Uses

func NewQueryFormat(params *piazza.JsonPagination) *QueryFormat

NewQueryFormat constructs a QueryFormat

type SearchResult Uses

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

func NewSearchResult Uses

func NewSearchResult(searchResult *elastic.SearchResult) *SearchResult

func (*SearchResult) GetHit Uses

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

func (*SearchResult) GetHits Uses

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

func (*SearchResult) NumHits Uses

func (r *SearchResult) NumHits() int

func (*SearchResult) TotalHits Uses

func (r *SearchResult) TotalHits() int64

type SearchResultHit Uses

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

Directories

PathSynopsis
elastic-5-api
elastic-5-api/uritemplatesPackage uritemplates is a level 4 implementation of RFC 6570 (URI Template, http://tools.ietf.org/html/rfc6570).

Package elasticsearch imports 10 packages (graph) and is imported by 4 packages. Updated 2018-06-02. Refresh now. Tools for package owners.