This commit implements a Search() function, which allow for running
search requests with both a query and aggregations. This function is
meant to more accurately implement the structure of search requests
accepted by ElasticSearch's Search API.
The Query() and Aggregate() functions are still included by the library,
but now simply call Search() internally, making them simple shortcuts.
Two new aggregations are also added: "terms" and "top_hits". These are
implemented a bit differently than previously implemented ones. The
structs and methods for ElasticSearch queries and aggregations will
eventually be auto-generated from a specification file, and will look
more like the new implementations of these new aggregations.
This commit performs the following modifications:
- The library is properly documented in Godoc format.
- The CustomQuery function is made to be a bit more versatile by
allowing it to also be used standalone (i.e. instead of passing a
`CustomQuery` as a parameter to the `Query` function, they now have
their own `Run` method).
- Queries and aggregations can now also be executed using the
`RunSearch` method. This method is the same as the `Run` method,
except that instead of an `*elasticSearch.Client` value, it accepts an
`esapi.Search` value. This is provided for consuming code that needs
to implement mock clients of ElasticSearch (e.g. for test purposes).
The ElasticSearch client does not provide an interface type describing
its API, so its Search function (which is actually a field of a
function type) can be used instead.
- Bugfix: the CustomAgg function was unusable as it did not accept a
name parameter and thus did not implement the Aggregation interface.
- Bugfix: the enumeration types are rewritten according to Go standards,
and the `RangeRelation` type's default value is now empty.
- The golint and godox linters are added.