elastic

package
v0.0.0-...-d31700d Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorNotFound = iota
	ErrorIndexAreadyExists
)

Variables

This section is empty.

Functions

func GenUUID

func GenUUID() string

func IsIndexAreadyExists

func IsIndexAreadyExists(err error) bool

func IsNotFound

func IsNotFound(err error) bool

Types

type BulkDeleteError

type BulkDeleteError interface {
	FailedItems() []string
	Error() string
}

type BulkError

type BulkError interface {
	FailedItems(ignoreMapperParsingException, ignoreIllegalArgumentException bool) [][2]interface{}
	Error() string
}

type BulkResult

type BulkResult struct {
	Errors bool                                `json:"errors"`
	Items  []map[string]map[string]interface{} `json:"items"`
}

reference: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html

type ES

type ES struct {
	BaseAddrs []string
	// contains filtered or unexported fields
}

func New

func New(addrs ...string) *ES

func New2

func New2(client *httputil.Client, addrs ...string) *ES

func (*ES) BulkCreate

func (es *ES) BulkCreate(path string, data [][2]interface{}) error

func (*ES) BulkDelete

func (es *ES) BulkDelete(path string, data []string) error

func (*ES) BulkDo

func (es *ES) BulkDo(path string, body, typ string, data [][2]interface{}) error

func (*ES) BulkIndex

func (es *ES) BulkIndex(path string, data [][2]interface{}) error

func (*ES) BulkUpdate

func (es *ES) BulkUpdate(path string, data [][2]interface{}) error

func (*ES) Create

func (es *ES) Create(path string, bodyData, data interface{}) error

创建

func (*ES) Delete

func (es *ES) Delete(path string, data interface{}) error

删除

func (*ES) Ensure

func (es *ES) Ensure(path string, def interface{}) error

Create if not Exist

func (*ES) Exist

func (es *ES) Exist(path string) (bool, error)

func (*ES) Get

func (es *ES) Get(path string, bodyData, data interface{}) error

func (*ES) Post

func (es *ES) Post(path string, bodyData, data interface{}) error

func (*ES) Put

func (es *ES) Put(path string, bodyData, data interface{}) error

覆盖

func (*ES) RootGet

func (es *ES) RootGet(path string, bodyData, data interface{}) error

func (*ES) RootPost

func (es *ES) RootPost(path string, bodyData, data interface{}) error

func (*ES) RootUri

func (es *ES) RootUri(path string) (string, error)

func (*ES) Search

func (es *ES) Search(path string, bodyData interface{}) (*SearchResult, error)

func (*ES) Update

func (es *ES) Update(path string, bodyData, data interface{}) error

更新

func (*ES) Uri

func (es *ES) Uri(path string) string

type Error

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

func (Error) Error

func (e Error) Error() string

type SearchHit

type SearchHit struct {
	Index  string          `json:"_index"`
	Type   string          `json:"_type"`
	Id     string          `json:"_id"`
	Score  float64         `json:"_score"`
	Source json.RawMessage `json:"_source"`
}

type SearchHits

type SearchHits struct {
	Total struct {
		Value    int    `json:"value"`
		Relation string `json:"relation"`
	} `json:"total"`
	Hits []SearchHit `json:"hits"`
}

func (SearchHits) Ids

func (h SearchHits) Ids() (data []string)

func (SearchHits) SetIds

func (h SearchHits) SetIds(data interface{}, key string)

func (SearchHits) Sources

func (h SearchHits) Sources(data interface{}) error

func (SearchHits) SourcesWithId

func (h SearchHits) SourcesWithId(data interface{}, key string) error

type SearchResult

type SearchResult struct {
	Took         int             `json:"took"`
	Timeout      bool            `json:"time_out"`
	Shards       Shards          `json:"_shards"`
	Hits         SearchHits      `json:"hits"`
	Aggregations json.RawMessage `json:"aggregations"`
}

type Shards

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

Jump to

Keyboard shortcuts

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