elastic icon indicating copy to clipboard operation
elastic copied to clipboard

elastic.SetDecoder() is not replacing all uses of the decoder

Open craigh1015 opened this issue 5 years ago • 1 comments

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?

craigh1015 avatar Jan 18 '20 07:01 craigh1015

Yes, the specified decoder is just used for the direct responses to service calls. I have to review if there is a simply change.

olivere avatar Jan 18 '20 15:01 olivere