Documentation ¶
Index ¶
- Constants
- type BulkRequest
- type BulkResponse
- type BulkResponseItem
- type Client
- func (c *Client) Bulk(items []*BulkRequest) (*BulkResponse, error)
- func (c *Client) CreateMapping(index string, docType string, mapping map[string]interface{}) error
- func (c *Client) Delete(index string, docType string, id string) error
- func (c *Client) DeleteIndex(index string) error
- func (c *Client) Do(method string, url string, body map[string]interface{}) (*Response, error)
- func (c *Client) DoBulk(url string, items []*BulkRequest) (*BulkResponse, error)
- func (c *Client) DoRequest(method string, url string, body *bytes.Buffer) (*http.Response, error)
- func (c *Client) Exists(index string, docType string, id string) (bool, error)
- func (c *Client) Get(index string, docType string, id string) (*Response, error)
- func (c *Client) GetMapping(index string, docType string) (*MappingResponse, error)
- func (c *Client) IndexBulk(index string, items []*BulkRequest) (*BulkResponse, error)
- func (c *Client) IndexTypeBulk(index string, docType string, items []*BulkRequest) (*BulkResponse, error)
- func (c *Client) Update(index string, docType string, id string, data map[string]interface{}) error
- type ClientConfig
- type Mapping
- type MappingResponse
- type Response
- type ResponseItem
Constants ¶
const ( ActionCreate = "create" ActionUpdate = "update" ActionDelete = "delete" ActionIndex = "index" )
See http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/bulk.html
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BulkRequest ¶
type BulkRequest struct { Action string Index string Type string ID string Parent string Pipeline string Data map[string]interface{} }
BulkRequest is used to send multi request in batch.
type BulkResponse ¶
type BulkResponse struct { Code int Took int `json:"took"` Errors bool `json:"errors"` Items []map[string]*BulkResponseItem `json:"items"` }
BulkResponse is the response for the bulk request.
type BulkResponseItem ¶
type BulkResponseItem struct { Index string `json:"_index"` Type string `json:"_type"` ID string `json:"_id"` Version int `json:"_version"` Status int `json:"status"` Error json.RawMessage `json:"error"` Found bool `json:"found"` }
BulkResponseItem is the item in the bulk response.
type Client ¶
type Client struct { Protocol string Addr string User string Password string // contains filtered or unexported fields }
Client is the client to communicate with ES. Although there are many Elasticsearch clients with Go, I still want to implement one by myself. Because we only need some very simple usages.
func NewClient ¶
func NewClient(conf *ClientConfig) *Client
NewClient creates the Cient with configuration.
func (*Client) Bulk ¶
func (c *Client) Bulk(items []*BulkRequest) (*BulkResponse, error)
Bulk sends the bulk request. only support parent in 'Bulk' related apis
func (*Client) CreateMapping ¶
CreateMapping creates a ES mapping.
func (*Client) DeleteIndex ¶
DeleteIndex deletes the index.
func (*Client) DoBulk ¶
func (c *Client) DoBulk(url string, items []*BulkRequest) (*BulkResponse, error)
DoBulk sends the bulk request to the ES.
func (*Client) GetMapping ¶
func (c *Client) GetMapping(index string, docType string) (*MappingResponse, error)
GetMapping gets the mapping.
func (*Client) IndexBulk ¶
func (c *Client) IndexBulk(index string, items []*BulkRequest) (*BulkResponse, error)
IndexBulk sends the bulk request for index.
func (*Client) IndexTypeBulk ¶
func (c *Client) IndexTypeBulk(index string, docType string, items []*BulkRequest) (*BulkResponse, error)
IndexTypeBulk sends the bulk request for index and doc type.
type ClientConfig ¶
ClientConfig is the configuration for the client.
type Mapping ¶
type Mapping map[string]struct { Mappings map[string]struct { Properties map[string]struct { Type string `json:"type"` Fields interface{} `json:"fields"` } `json:"properties"` } `json:"mappings"` }
Mapping represents ES mapping.
type MappingResponse ¶
MappingResponse is the response for the mapping request.