go-elasticsearch v8.4.0-alpha.1 Release Notes
-
๐ This prerelease introduces a new typed API generated from the elasticsearch-specification. This generation from the common specification allows us to provide a complete API which uses an exhaustive hierarchy of types reflecting the possibilities given by Elasticsearch.
๐ This new API is the next iteration of the Go client for Elasticsearch, it now lives alongside the existing API, it is in
alpha
state and will gain features over time and releases.What's new
๐ The
TypedClient
is built around a fluent builder for easier request creation and a collection of structures and helpers that mimics as closely as possible the Elasticsearch JSON API.As a first example, here is a search request:
cfg := elasticsearch.Config{ // Define your configuration } es, _ := elasticsearch.NewTypedClient(cfg) res, err := es.Search(). Index("index_name"). Request(&search.Request{ Query: &types.QueryContainer{ Match: map[types.Field]types.MatchQuery{ "name": {Query: "Foo"}, }, }, }, ).Do(context.Background())
๐ The
Request
uses the structures found in thetypedapi/types
package which will lead you along the possibilities. A builder for each structure that allows easier access and declaration is also provided.๐ More on the specifics and a few examples of standard use-cases can be found in the TypedAPI section of the documentation.
Limitations
๐ While most of the endpoints are covered, a few points are still being worked on and will be part of future releases:
- NDJSON endpoints:
bulk
,msearch
,msearch_template
,ML.post_data
,find_structure
, to name a few. - Response and Errors structures with deserialization.
Transport & config
๐ง While being different, the new API uses all the existing layers that were built so far,
elastic-transport-go
remains the preferred transport and all your configuration and credentials applies, same as before.Feedback
Feedback is very welcome, play with it, use it, let us know what you think!
- NDJSON endpoints: