Go: ElasticSearch Clients Study Case

Vincent
A Journey With Go
Published in
5 min readNov 1, 2019

--

Illustration created for “A Journey With Go”, made from the original Go Gopher, created by Renee French.

Choosing a package to consume ElasticSearch is the first step when setting a project up that uses it. This choice could impact the performance of your application if it is an important part of your workflow. However, there are few options with Go for this case: olivere/elastic is the most famous one, and the elastic/go-elasticsearch is the official client. Let’s review the pros and cons of each package.

Design

The libraries are designed in pretty different ways and, as consumers, we need to feel comfortable with the provided design. Let’s take a query in example and build in with both in order to see the difference. Here is the query:

The package olivere/elastic provides a full Query DSL (Domain Specific Language) that allows a total abstraction of the real query. Here is the built query:

And here is the query built with the official client:

--

--