Bugfix: Run() fails for queries, add MarshalJSON()
The `Run()` method on the `QueryRequest` type would fail, since it would
encode the _inner_ body of the query to JSON and not the complete, outer
body (i.e. including the "body: {}" portion).
The commit also adds `MarshalJSON()` methods to both `QueryRequest` and
`AggregationRequest`, allowing them to implement the `json.Marshaller`
interface, and providing easier debugging of the library. A test
skeleton for this is also added.
This commit is contained in:
@@ -40,6 +40,10 @@ func (req *AggregationRequest) Map() map[string]interface{} {
|
||||
}
|
||||
}
|
||||
|
||||
func (req *AggregationRequest) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(req.Map())
|
||||
}
|
||||
|
||||
func (req *AggregationRequest) Run(
|
||||
api *elasticsearch.Client,
|
||||
o ...func(*esapi.SearchRequest),
|
||||
|
||||
Reference in New Issue
Block a user