Skip to content

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

@craigh1015

Description

@craigh1015

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?

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions