Help us shape the future of Go! Take the 2026 Go Developer Survey

esclient

package module
v0.0.0-...-90f74e6 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2018 License: MIT Imports: 13 Imported by: 1

README

esclient

Simple client to Elastic Search

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewID

func NewID() string

func RecordChunks

func RecordChunks(in chan Record, chunkSize int) chan []Record

Types

type Client

type Client struct {
	HTTP      *rest.Client
	IndexName string
	DocType   string
}

func NewClient

func NewClient(config Config) *Client

func (*Client) Bulk

func (c *Client) Bulk(indexName string, records []Record) error

func (*Client) BulkOp

func (c *Client) BulkOp(fn func())

func (*Client) BulkText

func (c *Client) BulkText(indexName string, messages []string) error

func (*Client) CreateIndex

func (c *Client) CreateIndex(name string) error

func (*Client) CreateTemplate

func (c *Client) CreateTemplate(name string, template io.Reader) error

func (*Client) CreateTemplateFromFile

func (c *Client) CreateTemplateFromFile(name, filename string) error

func (*Client) DeleteIndex

func (c *Client) DeleteIndex(name string) error

func (*Client) DisableIndexing

func (c *Client) DisableIndexing(indexName string) error

func (*Client) EnableIndexing

func (c *Client) EnableIndexing(indexName string) error

func (*Client) IndexExists

func (c *Client) IndexExists(name string) bool

func (*Client) Push

func (c *Client) Push(indexName string, doc interface{}, id string) error

func (*Client) PushMessages

func (c *Client) PushMessages(in io.Reader, nobulk bool)

PushMessages bulk inserts to Elastic Search JSON lines without parsing

func (*Client) PushRaw

func (c *Client) PushRaw(indexName string, doc io.Reader, id string) error

func (*Client) Search

func (c *Client) Search(indexName string, request *SearchRequest, params *SearchParams) (*SearchResult, error)

func (*Client) SetRefreshInterval

func (c *Client) SetRefreshInterval(indexName, interval string) error

type Config

type Config struct {
	URL       string
	Username  string
	Password  string
	Verbose   bool
	Timeout   int64
	IndexName string
	DocType   string
}

type Hit

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

type Hits

type Hits struct {
	Total    int     `json:"total"`
	MaxScope float64 `json:"max_score"`
	Hits     []*Hit  `json:"hits"`
}

type Record

type Record map[string]interface{}

type SearchParams

type SearchParams struct {
	SearchType   string
	RequestCache bool
}

func (*SearchParams) IsEmpty

func (p *SearchParams) IsEmpty() bool

func (*SearchParams) String

func (p *SearchParams) String() string

type SearchRequest

type SearchRequest struct {
	Query          map[string]interface{} `json:"query"`
	From           int                    `json:"from,omitempty"`
	Size           int                    `json:"size,omitempty"`
	Timeout        *int                   `json:"timeout,omitempty"`
	TerminateAfter *int                   `json:"terminate_after,omitempty"`
}

type SearchResult

type SearchResult struct {
	TimedOut bool                   `json:"timed_out"`
	Took     float64                `json:"took"`
	Shards   map[string]interface{} `json:"_shards"`
	Hits     Hits                   `json:"hits"`
}

Jump to

Keyboard shortcuts

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