elastic
elastic copied to clipboard
elastic.SetDecoder() is not replacing all uses of the decoder
Which version of Elastic are you using?
[ ] elastic.v7 (for Elasticsearch 7.x)
Please describe the expected behavior
I am overriding the JSON decoder with a customer decoder
type JSONIterDecoder struct {}
func (d *JSONIterDecoder) Decode(data []byte, v interface{}) error {
return jsoniter.Unmarshal(data, v)
}
And then adding it to the client
return elastic.NewSimpleClient(
elastic.SetURL(esUrl),
elastic.SetDecoder(&JSONIterDecoder{})
)
I am expecting that the new decoder will be used for all processing with the client
Please describe the actual behavior
The flame-graphs generated from profiling show that v7.(*SearchService).Do is using jsoniter, however, v7.Aggregations.Terms and v7.Aggregations.TopHits are still using the encoding/json.
Are there further steps required to ensure that the decoder is replaced globally?
Yes, the specified decoder is just used for the direct responses to service calls. I have to review if there is a simply change.