Categorygithub.com/ttys3/elastic-wrapper-go
modulepackage
0.0.0-20231012005823-f16198b4c6d8
Repository: https://github.com/ttys3/elastic-wrapper-go.git
Documentation: pkg.go.dev

# README

elastic-wrapper-go

A tiny golang wrapper for elasticsearch-go client SDK, supporting common operations with friendly interfaces.

  1. tracing support
  2. typed api call
  3. response struct included

documentation

https://www.elastic.co/guide/en/elasticsearch/reference/8.4/api-conventions.html

JSON encoding

Elasticsearch only supports UTF-8-encoded JSON. Elasticsearch ignores any other encoding headings sent with a request. Responses are also UTF-8 encoded.

tracing

Elasticsearch also supports a traceparent HTTP header using the official W3C trace context spec. You can use the traceparent header to trace requests across Elastic products and other services. Because it’s only used for traces, you can safely generate a unique traceparent header for each request.

If provided, Elasticsearch surfaces the header’s trace-id value as trace.id in the:

JSON Elasticsearch server logs Slow logs Deprecation logs

GET and POST requests

A number of Elasticsearch GET APIs—​most notably the search API—​support a request body. While the GET action makes sense in the context of retrieving information, GET requests with a body are not supported by all HTTP libraries. All Elasticsearch GET APIs that require a body can also be submitted as POST requests. Alternatively, you can pass the request body as the source query string parameter when using GET.

REST API version compatibility

elasticsearch server REST API version compatibility

https://www.elastic.co/guide/en/elasticsearch/reference/8.4/api-conventions.html#api-compatibility

Number Values

All REST APIs support providing numbered parameters as string on top of supporting the native JSON number types.

Distance Units

Wherever distances need to be specified, such as the distance parameter in the Geo-distance, the default unit is meters if none is specified. Distances can be specified in other units, such as "1km" or "2mi" (2 miles).

The full list of units is listed below:

https://www.elastic.co/guide/en/elasticsearch/reference/8.4/api-conventions.html#distance-units

client SDK compatibility

https://www.elastic.co/guide/en/elasticsearch/client/go-api/current/installation.html#_elasticsearch_version_compatibility

Elasticsearch Version Compatibility

Language clients are forward compatible; meaning that clients support communicating with greater or equal minor versions of Elasticsearch.

Elasticsearch language clients are only backwards compatible with default distributions and without guarantees made.

Typed API

https://www.elastic.co/guide/en/elasticsearch/client/go-api/current/typedapi.html

  • go sdk v8 begin support Typed API

The goal for this API is to provide a strongly typed, fluent-like Golang API for Elasticsearch.

This was designed with structures and the Golang runtime in mind, following as closely as possible the API and its objects.

The first version focuses on the requests and does not yet include NDJSON endpoints such as bulk or msearch. These will be added later on along with typed responses and error handling.``

NDJSON and JSON streaming (https://en.wikipedia.org/wiki/JSON_streaming)

Newline delimited JSON is awesome

  • All the available endpoints are generated in separate packages and assembled in the client. The core namespace is duplicated at the root of the client for convenient access.

Each endpoint follows a factory pattern which returns a pointer to a new instance each time. This leads to a builder pattern allowing to directly chain the options before running your query.

  • Do need context, For body-empty endpoints such as core.Exists, an additional method IsSuccess is available.

  • Responsese: While not part of the initial release responses will be added at a later date.

# Packages

Package bulk_index implement bulk index documents api.
No description provided by the author
No description provided by the author

# Functions

FromJSONImplDefault is just a convenient func to avoid import json package everywhere.
No description provided by the author
No description provided by the author
No description provided by the author
NewJSONReader re-export esutil.NewJSONReader to avoid client code import esutil encodes v into JSON and returns it as an io.Reader.
No description provided by the author
NewTracingTransport uses *http.Transport which in stdlib and impl http.RoundTripper.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
BulkIndexError {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"The bulk request must be terminated by a newline [\\n]"}], "type":"illegal_argument_exception","reason":"The bulk request must be terminated by a newline [\\n]"},"status":400}.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ClusterInfoResponse is the response of ClusterInfo { "name" : "es01", "cluster_name" : "docker-cluster", "cluster_uuid" : "222qE0-PTtOtjmE7avMOgg", "version" : { "number" : "8.4.3", "build_flavor" : "default", "build_type" : "docker", "build_hash" : "42f05b9372a9a4a470db3b52817899b99a76ee73", "build_date" : "2022-10-04T07:17:24.662462378Z", "build_snapshot" : false, "lucene_version" : "9.3.0", "minimum_wire_compatibility_version" : "7.17.0", "minimum_index_compatibility_version" : "7.0.0" }, "tagline" : "You Know, for Search" } */.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GetLicenseResponse is the response of License { "license" : { "status" : "active", "uid" : "ab06dd7b-c292-4bd3-836e-81e6a633be07", "type" : "basic", "issue_date" : "2022-10-19T02:20:57.432Z", "issue_date_in_millis" : 1666146057432, "max_nodes" : 1000, "max_resource_units" : null, "issued_to" : "docker-cluster", "issuer" : "elasticsearch", "start_date_in_millis" : -1 } } */.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SearchResponseCustom custom search response with sort type support decode int64 > math.MaxFloat64.
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author