Documentation ¶
Index ¶
- Constants
- Variables
- func NewConfigSimple(addrURL, username, password string, tlsInsecureSkipVerify bool) elasticsearch.Config
- func NewSimpleClient(serverURL, username, password string, allowInsecure bool) (httpsimple.Client, error)
- type Client
- func (c *Client) DocumentCreate(target, id string, body any) (*http.Response, error)
- func (c *Client) DocumentRead(target, id string, v any) (*DocumentReadAPIResponse, *http.Response, error)
- func (c *Client) DocumentReadSimple(target, id string) (*http.Response, error)
- func (c *Client) IndexCreate(target string, body any) (*http.Response, error)
- func (c *Client) IndexPatch(target string, body any) (*http.Response, error)
- type DocumentReadAPIResponse
Constants ¶
const ( // DefaultScheme is the HTTP scheme for the default server. DefaultScheme string = "https" // DefaultHost is the HTTP host for the default server. DefaultHost string = "127.0.0.1:9200" // DefaultServerURL is the HTTP host for the default server. DefaultServerURL string = "https://127.0.0.1:9200" MappingFieldKeyword = "keyword" // see: https://www.elastic.co/blog/strings-are-dead-long-live-strings MappingFieldRaw = "raw" // SlugCreate is the URL path part for creates. SlugCreate = "_create" SlugDoc = "_doc" SlugMapping = "_mapping" // SlugSearch is the URL path part for search. SlugSearch = "_search" // SlugUpdate is the URL path part for updates. SlugUpdate = "_update" TypeInteger = "integer" // More at: https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html TypeKeyword = "keyword" TypeString = "string" // Deprecation in ES5: https://www.elastic.co/blog/strings-are-dead-long-live-strings TypeText = "text" TypeMatchOnlyText = "match_only_text" )
Variables ¶
Functions ¶
func NewConfigSimple ¶
func NewConfigSimple(addrURL, username, password string, tlsInsecureSkipVerify bool) elasticsearch.Config
func NewSimpleClient ¶
func NewSimpleClient(serverURL, username, password string, allowInsecure bool) (httpsimple.Client, error)
Types ¶
type Client ¶
type Client struct {
SimpleClient *httpsimple.Client
}
func (*Client) DocumentCreate ¶
DocumentCreate crates a document with the document id `id`. If `id` is empty, a document id is created.`
func (*Client) DocumentRead ¶
func (c *Client) DocumentRead(target, id string, v any) (*DocumentReadAPIResponse, *http.Response, error)
DocumentRead reads a document. If `v` is a pointer, the resulting `_source` property will be unmarshaled into it. The API is documented at: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html and https://www.elastic.co/guide/en/elasticsearch/client/go-api/current/examples.html#retrieving_document .
func (*Client) DocumentReadSimple ¶ added in v0.6.0
DocumentRead reads a document. Documented at: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html .
func (*Client) IndexCreate ¶
IndexCreate creates an index. Documented at: https://www.elastic.co/guide/en/elasticsearch/reference/current/explicit-mapping.html .
func (*Client) IndexPatch ¶
IndexPatch patches an index. Documented at: https://www.elastic.co/guide/en/elasticsearch/reference/current/explicit-mapping.html#add-field-mapping .
type DocumentReadAPIResponse ¶ added in v0.6.0
type DocumentReadAPIResponse struct { Index string `json:"_index"` ID string `json:"_id"` Found bool `json:"found"` Source json.RawMessage `json:"_source"` }
DocumentReadAPIResponse represents an Elasticsearch document response.