elastirad

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 License: MIT Imports: 7 Imported by: 0

README

Elastirad: A Go Client Wrapper for Elasticsearch

Build Status Go Report Card Docs License

Simple client to query Elasticsearch API using HTTP API documentation. This is inspired by the Elastirad Ruby gem.

Usage

See the sample code in the docs folder.

So far the following example code has been created:

  1. Create Index: Go code, ES docs
  2. Index Docs: Go code, ES docs
  3. Bool Query: Go code, ES docs
  4. Terms Aggregation: Go code, ES docs

Documentation

Index

Constants

View Source
const (
	// ElasticsearchAPIDefaultScheme is the HTTP scheme for the default server.
	ElasticsearchAPIDefaultScheme string = "http"
	// ElasticsearchAPIDefaultHost is the HTTP host for the default server.
	ElasticsearchAPIDefaultHost string = "127.0.0.1:9200"
	// CreateSlug is the URL path part for creates.
	CreateSlug string = "_create"
	// UpdateSlug is the URL path part for updates.
	UpdateSlug string = "_update"
	// SearchSlug is the URL path part for search.
	SearchSlug string = "_search"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL        url.URL
	FastHTTPClient fasthttp.Client
}

Client is a API client for Elasticsearch.

func NewClient

func NewClient(baseURL url.URL) Client

NewClient returns a Client struct given a Elasticsearch server URL.

func (*Client) BuildFastRequest

func (c *Client) BuildFastRequest(esReq models.Request) (*fasthttp.Request, error)

BuildFastRequest builds a valyala/fasthttp HTTP request struct.

func (*Client) BuildURL

func (c *Client) BuildURL(esReq models.Request) url.URL

BuildURL merges the URL info in the request with the Elasticsearch server info configured in the client.

func (*Client) SendFastRequest

func (c *Client) SendFastRequest(esReq models.Request) (*fasthttp.Response, *fasthttp.Request, error)

SendFastRequest executes a valyala/fasthttp HTTP request and returns the response, request and error structs.

func (*Client) SetDefaults

func (c *Client) SetDefaults()

SetDefaults sets default values where not specified.

Jump to

Keyboard shortcuts

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