# README
elastic-wrapper-go
A tiny golang wrapper for elasticsearch-go client SDK, supporting common operations with friendly interfaces.
- tracing support
- typed api call
- 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 uniquetraceparent
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
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
needcontext
, For body-empty endpoints such ascore.Exists
, an additional methodIsSuccess
is available. -
Responsese: While not part of the initial release responses will be added at a later date.